ndtypes 0.2.0dev5 → 0.2.0dev6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +12 -0
  3. data/Rakefile +8 -0
  4. data/ext/ruby_ndtypes/GPATH +0 -0
  5. data/ext/ruby_ndtypes/GRTAGS +0 -0
  6. data/ext/ruby_ndtypes/GTAGS +0 -0
  7. data/ext/ruby_ndtypes/extconf.rb +1 -1
  8. data/ext/ruby_ndtypes/include/ndtypes.h +231 -122
  9. data/ext/ruby_ndtypes/include/ruby_ndtypes.h +1 -1
  10. data/ext/ruby_ndtypes/lib/libndtypes.a +0 -0
  11. data/ext/ruby_ndtypes/lib/libndtypes.so.0.2.0dev3 +0 -0
  12. data/ext/ruby_ndtypes/ndtypes/Makefile +87 -0
  13. data/ext/ruby_ndtypes/ndtypes/config.h +68 -0
  14. data/ext/ruby_ndtypes/ndtypes/config.log +477 -0
  15. data/ext/ruby_ndtypes/ndtypes/config.status +1027 -0
  16. data/ext/ruby_ndtypes/ndtypes/doc/_static/style.css +7 -0
  17. data/ext/ruby_ndtypes/ndtypes/doc/_templates/layout.html +2 -0
  18. data/ext/ruby_ndtypes/ndtypes/doc/conf.py +40 -4
  19. data/ext/ruby_ndtypes/ndtypes/doc/images/xndlogo.png +0 -0
  20. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/types.rst +1 -1
  21. data/ext/ruby_ndtypes/ndtypes/doc/requirements.txt +2 -0
  22. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile +287 -0
  23. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.in +20 -4
  24. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.vc +22 -3
  25. data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.c +1 -1
  26. data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.o +0 -0
  27. data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.o +0 -0
  28. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile +73 -0
  29. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.c +246 -229
  30. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.h +15 -11
  31. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.o +0 -0
  32. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.y +38 -28
  33. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.c +91 -91
  34. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.h +1 -1
  35. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.l +4 -3
  36. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.o +0 -0
  37. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.c +8 -7
  38. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.o +0 -0
  39. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.c +2 -2
  40. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.o +0 -0
  41. data/ext/ruby_ndtypes/ndtypes/libndtypes/context.o +0 -0
  42. data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.c +263 -182
  43. data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.o +0 -0
  44. data/ext/ruby_ndtypes/ndtypes/libndtypes/encodings.o +0 -0
  45. data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.c +67 -7
  46. data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.o +0 -0
  47. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +1112 -1000
  48. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.h +69 -58
  49. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.o +0 -0
  50. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +150 -99
  51. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +185 -15
  52. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.o +0 -0
  53. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.c +301 -276
  54. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.h +1 -1
  55. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.l +9 -4
  56. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.o +0 -0
  57. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.a +0 -0
  58. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so +1 -0
  59. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0 +1 -0
  60. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0.2.0dev3 +0 -0
  61. data/ext/ruby_ndtypes/ndtypes/libndtypes/match.c +729 -228
  62. data/ext/ruby_ndtypes/ndtypes/libndtypes/match.o +0 -0
  63. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.c +768 -403
  64. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h +1002 -0
  65. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h.in +231 -122
  66. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.o +0 -0
  67. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.c +176 -84
  68. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.h +26 -14
  69. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.o +0 -0
  70. data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.c +57 -35
  71. data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.o +0 -0
  72. data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.c +420 -0
  73. data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.o +0 -0
  74. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.c +8 -8
  75. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.h +1 -1
  76. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.o +0 -0
  77. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile +48 -0
  78. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.c +200 -116
  79. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.o +0 -0
  80. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.c +46 -4
  81. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.o +0 -0
  82. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.c +58 -27
  83. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.h +1 -1
  84. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.o +0 -0
  85. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.c +3 -5
  86. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.h +12 -4
  87. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.o +0 -0
  88. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile +55 -0
  89. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.in +8 -8
  90. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.vc +5 -5
  91. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/runtest.c +274 -172
  92. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test.h +24 -4
  93. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_array.c +2 -2
  94. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_buffer.c +14 -14
  95. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +32 -30
  96. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +37 -0
  97. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +36 -0
  98. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +16 -0
  99. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_record.c +5 -5
  100. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +706 -253
  101. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_unify.c +132 -0
  102. data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.c +703 -0
  103. data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.o +0 -0
  104. data/ext/ruby_ndtypes/ndtypes/libndtypes/util.c +335 -127
  105. data/ext/ruby_ndtypes/ndtypes/libndtypes/util.o +0 -0
  106. data/ext/ruby_ndtypes/ndtypes/libndtypes/values.c +2 -2
  107. data/ext/ruby_ndtypes/ndtypes/libndtypes/values.o +0 -0
  108. data/ext/ruby_ndtypes/ndtypes/python/ndt_randtype.py +88 -71
  109. data/ext/ruby_ndtypes/ndtypes/python/ndt_support.py +0 -1
  110. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/__init__.py +10 -13
  111. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +395 -314
  112. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.a +0 -0
  113. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so +1 -0
  114. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0 +1 -0
  115. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0.2.0dev3 +0 -0
  116. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/ndtypes.h +1002 -0
  117. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/pyndtypes.h +15 -33
  118. data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +340 -132
  119. data/ext/ruby_ndtypes/ndtypes/setup.py +11 -2
  120. data/ext/ruby_ndtypes/ruby_ndtypes.c +364 -241
  121. data/ext/ruby_ndtypes/ruby_ndtypes.h +1 -1
  122. data/ext/ruby_ndtypes/ruby_ndtypes_internal.h +0 -1
  123. data/lib/ndtypes.rb +11 -0
  124. data/lib/ndtypes/version.rb +2 -2
  125. data/lib/ruby_ndtypes.so +0 -0
  126. data/ndtypes.gemspec +3 -0
  127. data/spec/ndtypes_spec.rb +6 -0
  128. metadata +98 -4
  129. data/ext/ruby_ndtypes/gc_guard.c +0 -36
  130. data/ext/ruby_ndtypes/gc_guard.h +0 -12
@@ -1,8 +1,9 @@
1
- /* A Bison parser, made by GNU Bison 3.0.4. */
1
+ /* A Bison parser, made by GNU Bison 3.3. */
2
2
 
3
3
  /* Bison interface for Yacc-like parsers in C
4
4
 
5
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
5
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6
+ Inc.
6
7
 
7
8
  This program is free software: you can redistribute it and/or modify
8
9
  it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
30
31
  This special exception was added by the Free Software Foundation in
31
32
  version 2.2 of Bison. */
32
33
 
34
+ /* Undocumented macros, especially those whose name start with YY_,
35
+ are private implementation details. Do not rely on them. */
36
+
33
37
  #ifndef YY_NDT_YY_GRAMMAR_H_INCLUDED
34
38
  # define YY_NDT_YY_GRAMMAR_H_INCLUDED
35
39
  /* Debug traces. */
@@ -40,7 +44,7 @@
40
44
  extern int ndt_yydebug;
41
45
  #endif
42
46
  /* "%code requires" blocks. */
43
- #line 57 "grammar.y" /* yacc.c:1909 */
47
+ #line 56 "grammar.y" /* yacc.c:1921 */
44
48
 
45
49
  #include "ndtypes.h"
46
50
  #include "seq.h"
@@ -49,7 +53,7 @@ extern int ndt_yydebug;
49
53
  #define YY_TYPEDEF_YY_SCANNER_T
50
54
  typedef void * yyscan_t;
51
55
 
52
- #line 53 "grammar.h" /* yacc.c:1909 */
56
+ #line 57 "grammar.h" /* yacc.c:1921 */
53
57
 
54
58
  /* Token type. */
55
59
  #ifndef YYTOKENTYPE
@@ -72,53 +76,58 @@ extern int ndt_yydebug;
72
76
  UINT32 = 270,
73
77
  UINT64 = 271,
74
78
  FLOAT_KIND = 272,
75
- FLOAT16 = 273,
76
- FLOAT32 = 274,
77
- FLOAT64 = 275,
78
- COMPLEX_KIND = 276,
79
- COMPLEX32 = 277,
80
- COMPLEX64 = 278,
81
- COMPLEX128 = 279,
82
- CATEGORICAL = 280,
83
- NA = 281,
84
- INTPTR = 282,
85
- UINTPTR = 283,
86
- SIZE = 284,
87
- CHAR = 285,
88
- STRING = 286,
89
- FIXED_STRING_KIND = 287,
90
- FIXED_STRING = 288,
91
- BYTES = 289,
92
- FIXED_BYTES_KIND = 290,
93
- FIXED_BYTES = 291,
94
- REF = 292,
95
- FIXED = 293,
96
- VAR = 294,
97
- COMMA = 295,
98
- COLON = 296,
99
- LPAREN = 297,
100
- RPAREN = 298,
101
- LBRACE = 299,
102
- RBRACE = 300,
103
- LBRACK = 301,
104
- RBRACK = 302,
105
- STAR = 303,
106
- ELLIPSIS = 304,
107
- RARROW = 305,
108
- EQUAL = 306,
109
- LESS = 307,
110
- GREATER = 308,
111
- QUESTIONMARK = 309,
112
- BANG = 310,
113
- AMPERSAND = 311,
114
- BAR = 312,
115
- ERRTOKEN = 313,
116
- INTEGER = 314,
117
- FLOATNUMBER = 315,
118
- STRINGLIT = 316,
119
- NAME_LOWER = 317,
120
- NAME_UPPER = 318,
121
- NAME_OTHER = 319
79
+ BFLOAT16 = 273,
80
+ FLOAT16 = 274,
81
+ FLOAT32 = 275,
82
+ FLOAT64 = 276,
83
+ COMPLEX_KIND = 277,
84
+ BCOMPLEX32 = 278,
85
+ COMPLEX32 = 279,
86
+ COMPLEX64 = 280,
87
+ COMPLEX128 = 281,
88
+ CATEGORICAL = 282,
89
+ NA = 283,
90
+ INTPTR = 284,
91
+ UINTPTR = 285,
92
+ SIZE = 286,
93
+ CHAR = 287,
94
+ STRING = 288,
95
+ FIXED_STRING_KIND = 289,
96
+ FIXED_STRING = 290,
97
+ BYTES = 291,
98
+ FIXED_BYTES_KIND = 292,
99
+ FIXED_BYTES = 293,
100
+ REF = 294,
101
+ FIXED = 295,
102
+ VAR = 296,
103
+ ARRAY = 297,
104
+ OF = 298,
105
+ COMMA = 299,
106
+ COLON = 300,
107
+ LPAREN = 301,
108
+ RPAREN = 302,
109
+ LBRACE = 303,
110
+ RBRACE = 304,
111
+ LBRACK = 305,
112
+ RBRACK = 306,
113
+ STAR = 307,
114
+ ELLIPSIS = 308,
115
+ RARROW = 309,
116
+ EQUAL = 310,
117
+ LESS = 311,
118
+ GREATER = 312,
119
+ QUESTIONMARK = 313,
120
+ BANG = 314,
121
+ AMPERSAND = 315,
122
+ BAR = 316,
123
+ ERRTOKEN = 317,
124
+ INTEGER = 318,
125
+ FLOATNUMBER = 319,
126
+ STRINGLIT = 320,
127
+ NAME_LOWER = 321,
128
+ NAME_UPPER = 322,
129
+ NAME_OTHER = 323,
130
+ BELOW_BAR = 324
122
131
  };
123
132
  #endif
124
133
 
@@ -127,9 +136,11 @@ extern int ndt_yydebug;
127
136
 
128
137
  union YYSTYPE
129
138
  {
130
- #line 86 "grammar.y" /* yacc.c:1909 */
139
+ #line 85 "grammar.y" /* yacc.c:1921 */
131
140
 
132
- ndt_t *ndt;
141
+ const ndt_t *ndt;
142
+ enum ndt tag;
143
+ enum ndt_alias alias;
133
144
  ndt_field_t *field;
134
145
  ndt_field_seq_t *field_seq;
135
146
  ndt_value_t *typed_value;
@@ -143,7 +154,7 @@ union YYSTYPE
143
154
  ndt_string_seq_t *string_seq;
144
155
  ndt_type_seq_t *type_seq;
145
156
 
146
- #line 147 "grammar.h" /* yacc.c:1909 */
157
+ #line 158 "grammar.h" /* yacc.c:1921 */
147
158
  };
148
159
 
149
160
  typedef union YYSTYPE YYSTYPE;
@@ -167,14 +178,14 @@ struct YYLTYPE
167
178
 
168
179
 
169
180
 
170
- int ndt_yyparse (yyscan_t scanner, ndt_t **ast, ndt_meta_t *meta, ndt_context_t *ctx);
181
+ int ndt_yyparse (yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx);
171
182
  /* "%code provides" blocks. */
172
- #line 66 "grammar.y" /* yacc.c:1909 */
183
+ #line 65 "grammar.y" /* yacc.c:1921 */
173
184
 
174
185
  #define YY_DECL extern int ndt_yylexfunc(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, ndt_context_t *ctx)
175
186
  extern int ndt_yylexfunc(YYSTYPE *, YYLTYPE *, yyscan_t, ndt_context_t *);
176
- void yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_meta_t *meta, ndt_context_t *ctx, const char *msg);
187
+ void yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx, const char *msg);
177
188
 
178
- #line 179 "grammar.h" /* yacc.c:1909 */
189
+ #line 190 "grammar.h" /* yacc.c:1921 */
179
190
 
180
191
  #endif /* !YY_NDT_YY_GRAMMAR_H_INCLUDED */
@@ -36,12 +36,11 @@
36
36
 
37
37
 
38
38
  void
39
- yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_meta_t *meta,
40
- ndt_context_t *ctx, const char *msg)
39
+ yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx,
40
+ const char *msg)
41
41
  {
42
42
  (void)scanner;
43
43
  (void)ast;
44
- (void)meta;
45
44
 
46
45
  ndt_err_format(ctx, NDT_ParseError, "%d:%d: %s", loc->first_line,
47
46
  loc->first_column, msg);
@@ -66,11 +65,11 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
66
65
  %code provides {
67
66
  #define YY_DECL extern int ndt_yylexfunc(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, ndt_context_t *ctx)
68
67
  extern int ndt_yylexfunc(YYSTYPE *, YYLTYPE *, yyscan_t, ndt_context_t *);
69
- void yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_meta_t *meta, ndt_context_t *ctx, const char *msg);
68
+ void yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx, const char *msg);
70
69
  }
71
70
 
72
71
  %pure-parser
73
- %error-verbose
72
+ %define parse.error verbose
74
73
 
75
74
  %locations
76
75
  %initial-action {
@@ -81,10 +80,12 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
81
80
  }
82
81
 
83
82
  %lex-param {yyscan_t scanner} {ndt_context_t *ctx}
84
- %parse-param {yyscan_t scanner} {ndt_t **ast} {ndt_meta_t *meta} {ndt_context_t *ctx}
83
+ %parse-param {yyscan_t scanner} {const ndt_t **ast} {ndt_context_t *ctx}
85
84
 
86
85
  %union {
87
- ndt_t *ndt;
86
+ const ndt_t *ndt;
87
+ enum ndt tag;
88
+ enum ndt_alias alias;
88
89
  ndt_field_t *field;
89
90
  ndt_field_seq_t *field_seq;
90
91
  ndt_value_t *typed_value;
@@ -110,16 +111,20 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
110
111
  %type <ndt> dimensions_tail
111
112
  %type <ndt> dtype
112
113
  %type <ndt> scalar
113
- %type <ndt> signed
114
- %type <ndt> unsigned
115
- %type <ndt> ieee_float
116
- %type <ndt> ieee_complex
117
- %type <ndt> alias
114
+
115
+ %type <tag> signed
116
+ %type <tag> unsigned
117
+ %type <tag> ieee_float
118
+ %type <tag> ieee_complex
119
+ %type <alias> alias
120
+
118
121
  %type <ndt> character
119
122
  %type <ndt> string
120
123
  %type <ndt> fixed_string
121
124
  %type <ndt> bytes
122
125
  %type <ndt> fixed_bytes
126
+ %type <ndt> array_dimensions
127
+ %type <ndt> array
123
128
  %type <ndt> ref
124
129
 
125
130
  %type <ndt> tuple_type
@@ -129,7 +134,12 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
129
134
  %type <ndt> record_type
130
135
  %type <field> record_field
131
136
  %type <field_seq> record_field_seq
132
- %type <string> record_field_name
137
+
138
+ %type <ndt> union_type
139
+ %type <field> union_member
140
+ %type <field_seq> union_member_seq
141
+
142
+ %type <string> field_name_or_tag
133
143
 
134
144
  %type <ndt> categorical
135
145
  %type <typed_value> typed_value
@@ -148,6 +158,8 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
148
158
 
149
159
  %type <ndt> function_type
150
160
 
161
+ %type <uint32> flags_opt
162
+ %type <uint32> option_opt
151
163
  %type <uint32> endian_opt
152
164
  %type <encoding> encoding
153
165
  %type <variadic_flag> variadic_flag
@@ -160,8 +172,8 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
160
172
  BOOL
161
173
  SIGNED_KIND INT8 INT16 INT32 INT64
162
174
  UNSIGNED_KIND UINT8 UINT16 UINT32 UINT64
163
- FLOAT_KIND FLOAT16 FLOAT32 FLOAT64
164
- COMPLEX_KIND COMPLEX32 COMPLEX64 COMPLEX128
175
+ FLOAT_KIND BFLOAT16 FLOAT16 FLOAT32 FLOAT64
176
+ COMPLEX_KIND BCOMPLEX32 COMPLEX32 COMPLEX64 COMPLEX128
165
177
  CATEGORICAL NA
166
178
  INTPTR UINTPTR SIZE
167
179
  CHAR
@@ -169,7 +181,7 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
169
181
  BYTES FIXED_BYTES_KIND FIXED_BYTES
170
182
  REF
171
183
 
172
- FIXED VAR
184
+ FIXED VAR ARRAY OF
173
185
 
174
186
  COMMA COLON LPAREN RPAREN LBRACE RBRACE LBRACK RBRACK STAR ELLIPSIS
175
187
  RARROW EQUAL LESS GREATER QUESTIONMARK BANG AMPERSAND BAR
@@ -181,7 +193,7 @@ ERRTOKEN
181
193
 
182
194
  %token ENDMARKER 0 "end of file"
183
195
 
184
- %destructor { ndt_del($$); } <ndt>
196
+ %destructor { ndt_decref($$); } <ndt>
185
197
  %destructor { ndt_field_del($$); } <field>
186
198
  %destructor { ndt_field_seq_del($$); } <field_seq>
187
199
  %destructor { ndt_value_del($$); } <typed_value>
@@ -192,6 +204,10 @@ ERRTOKEN
192
204
  %destructor { ndt_string_seq_del($$); } <string_seq>
193
205
  %destructor { ndt_type_seq_del($$); } <type_seq>
194
206
 
207
+ %token BELOW_BAR
208
+ %precedence BELOW_BAR
209
+ %precedence BAR
210
+
195
211
  %%
196
212
 
197
213
  input:
@@ -201,114 +217,122 @@ input:
201
217
  datashape_or_module:
202
218
  datashape_with_ellipsis { $$ = $1; }
203
219
  | function_type { $$ = $1; }
204
- | NAME_UPPER COLON COLON datashape_with_ellipsis { $$ = ndt_module($1, $4, ctx); if ($$ == NULL) YYABORT; }
220
+ | NAME_UPPER COLON COLON datashape_with_ellipsis { $$ = mk_module($1, $4, ctx); if ($$ == NULL) YYABORT; }
205
221
 
206
222
  /* types */
207
223
  datashape_with_ellipsis:
208
224
  datashape { $$ = $1; }
209
225
  | fixed_ellipsis { $$ = $1; }
210
- | NAME_UPPER LBRACK fixed_ellipsis RBRACK { $$ = mk_contig($1, $3, ctx); if ($$ == NULL) YYABORT; }
226
+ | NAME_UPPER LBRACK fixed_ellipsis RBRACK { $$ = mk_contig($1, (ndt_t *)$3, ctx); if ($$ == NULL) YYABORT; }
211
227
  | VAR ELLIPSIS STAR dtype { $$ = mk_var_ellipsis($4, ctx); if ($$ == NULL) YYABORT; }
212
- | VAR ELLIPSIS STAR QUESTIONMARK dtype { $$ = mk_var_ellipsis(ndt_option($5), ctx); if ($$ == NULL) YYABORT; }
228
+ | array_dimensions { $$ = $1; }
213
229
 
214
230
  fixed_ellipsis:
215
- ELLIPSIS STAR dimensions_tail { $$ = ndt_ellipsis_dim(NULL, $3, ctx); if ($$ == NULL) YYABORT; }
216
- | NAME_UPPER ELLIPSIS STAR dimensions_tail { $$ = ndt_ellipsis_dim($1, $4, ctx); if ($$ == NULL) YYABORT; }
231
+ ELLIPSIS STAR dimensions_tail { $$ = mk_ellipsis_dim(NULL, $3, ctx); if ($$ == NULL) YYABORT; }
232
+ | NAME_UPPER ELLIPSIS STAR dimensions_tail { $$ = mk_ellipsis_dim($1, $4, ctx); if ($$ == NULL) YYABORT; }
217
233
 
218
234
  datashape:
219
235
  dimensions { $$ = $1; }
220
236
  | dtype { $$ = $1; }
221
- | QUESTIONMARK dtype { $$ = ndt_option($2); if ($$ == NULL) YYABORT; }
222
237
 
223
238
  dimensions:
224
239
  dimensions_nooption { $$ = $1; }
225
- | QUESTIONMARK dimensions_nooption { $$ = ndt_option($2); if ($$ == NULL) YYABORT; }
226
- | NAME_UPPER LBRACK dimensions RBRACK { $$ = mk_contig($1, $3, ctx); if ($$ == NULL) YYABORT; }
240
+ | NAME_UPPER LBRACK dimensions RBRACK { $$ = mk_contig($1, (ndt_t *)$3, ctx); if ($$ == NULL) YYABORT; }
227
241
  | BANG dimensions { $$ = mk_fortran($2, ctx); if ($$ == NULL) YYABORT; }
228
242
 
229
243
  dimensions_nooption:
230
244
  INTEGER STAR dimensions_tail { $$ = mk_fixed_dim_from_shape($1, $3, ctx); if ($$ == NULL) YYABORT; }
231
245
  | FIXED LPAREN attribute_seq RPAREN STAR dimensions_tail { $$ = mk_fixed_dim_from_attrs($3, $6, ctx); if ($$ == NULL) YYABORT; }
232
- | NAME_UPPER STAR dimensions_tail { $$ = ndt_symbolic_dim($1, $3, ctx); if ($$ == NULL) YYABORT; }
233
- | VAR arguments_opt STAR dimensions_tail { $$ = mk_var_dim(meta, $2, $4, ctx); if ($$ == NULL) YYABORT; }
246
+ | NAME_UPPER STAR dimensions_tail { $$ = mk_symbolic_dim($1, $3, ctx); if ($$ == NULL) YYABORT; }
247
+ | VAR arguments_opt STAR dimensions_tail { $$ = mk_var_dim($2, $4, false, ctx); if ($$ == NULL) YYABORT; }
248
+ | QUESTIONMARK VAR arguments_opt STAR dimensions_tail { $$ = mk_var_dim($3, $5, true, ctx); if ($$ == NULL) YYABORT; }
249
+
234
250
 
235
251
  dimensions_tail:
236
252
  dtype { $$ = $1; }
237
- | QUESTIONMARK dtype { $$ = ndt_option($2); if ($$ == NULL) YYABORT; }
238
253
  | dimensions { $$ = $1; }
239
254
 
240
255
  dtype:
241
- ANY_KIND { $$ = ndt_any_kind(ctx); if ($$ == NULL) YYABORT; }
242
- | SCALAR_KIND { $$ = ndt_scalar_kind(ctx); if ($$ == NULL) YYABORT; }
243
- | scalar { $$ = $1; }
244
- | tuple_type { $$ = $1; }
245
- | record_type { $$ = $1; }
246
- | NAME_LOWER { $$ = ndt_nominal($1, NULL, ctx); if ($$ == NULL) YYABORT; }
247
- | NAME_UPPER LPAREN datashape RPAREN { $$ = ndt_constr($1, $3, ctx); if ($$ == NULL) YYABORT; }
248
- | NAME_UPPER LPAREN attribute_seq RPAREN { (void)$1; (void)$3; ndt_free($1); ndt_attr_seq_del($3); $$ = NULL;
249
- ndt_err_format(ctx, NDT_NotImplementedError, "general attributes are not implemented");
250
- YYABORT; }
251
- | NAME_UPPER { $$ = ndt_typevar($1, ctx); if ($$ == NULL) YYABORT; }
256
+ option_opt ANY_KIND { $$ = ndt_any_kind($1, ctx); if ($$ == NULL) YYABORT; }
257
+ | option_opt SCALAR_KIND { $$ = ndt_scalar_kind($1, ctx); if ($$ == NULL) YYABORT; }
258
+ | scalar { $$ = $1; }
259
+ | tuple_type { $$ = $1; }
260
+ | record_type { $$ = $1; }
261
+ | union_type { $$ = $1; }
262
+ | NAME_LOWER { $$ = ndt_nominal($1, NULL, false, ctx); if ($$ == NULL) YYABORT; }
263
+ | QUESTIONMARK NAME_LOWER { $$ = ndt_nominal($2, NULL, true, ctx); if ($$ == NULL) YYABORT; }
264
+ | NAME_UPPER LPAREN datashape RPAREN { $$ = mk_constr($1, $3, false, ctx); if ($$ == NULL) YYABORT; }
265
+ | QUESTIONMARK NAME_UPPER LPAREN datashape RPAREN { $$ = mk_constr($2, $4, true, ctx); if ($$ == NULL) YYABORT; }
266
+ | NAME_UPPER { $$ = ndt_typevar($1, ctx); if ($$ == NULL) YYABORT; }
252
267
 
253
268
  scalar:
254
- endian_opt BOOL { $$ = ndt_primitive(Bool, $1, ctx); if ($$ == NULL) YYABORT; }
255
- | SIGNED_KIND { $$ = ndt_signed_kind(ctx); if ($$ == NULL) YYABORT; }
256
- | signed { $$ = $1; }
257
- | UNSIGNED_KIND { $$ = ndt_unsigned_kind(ctx); if ($$ == NULL) YYABORT; }
258
- | unsigned { $$ = $1; }
259
- | FLOAT_KIND { $$ = ndt_float_kind(ctx); if ($$ == NULL) YYABORT; }
260
- | ieee_float { $$ = $1; }
261
- | COMPLEX_KIND { $$ = ndt_complex_kind(ctx); if ($$ == NULL) YYABORT; }
262
- | ieee_complex { $$ = $1; }
263
- | alias { $$ = $1; }
264
- | character { $$ = $1; }
265
- | string { $$ = $1; }
266
- | FIXED_STRING_KIND { $$ = ndt_fixed_string_kind(ctx); if ($$ == NULL) YYABORT; }
267
- | fixed_string { $$ = $1; }
268
- | bytes { $$ = $1; }
269
- | FIXED_BYTES_KIND { $$ = ndt_fixed_bytes_kind(ctx); if ($$ == NULL) YYABORT; }
270
- | fixed_bytes { $$ = $1; }
271
- | categorical { $$ = $1; }
272
- | ref { $$ = $1; }
269
+ flags_opt BOOL { $$ = ndt_primitive(Bool, $1, ctx); if ($$ == NULL) YYABORT; }
270
+ | flags_opt SIGNED_KIND { $$ = ndt_signed_kind($1, ctx); if ($$ == NULL) YYABORT; }
271
+ | flags_opt signed { $$ = ndt_primitive($2, $1, ctx); if ($$ == NULL) YYABORT; }
272
+ | flags_opt UNSIGNED_KIND { $$ = ndt_unsigned_kind($1, ctx); if ($$ == NULL) YYABORT; }
273
+ | flags_opt unsigned { $$ = ndt_primitive($2, $1, ctx); if ($$ == NULL) YYABORT; }
274
+ | flags_opt FLOAT_KIND { $$ = ndt_float_kind($1, ctx); if ($$ == NULL) YYABORT; }
275
+ | flags_opt BFLOAT16 { $$ = ndt_primitive(BFloat16, $1, ctx); if ($$ == NULL) YYABORT; }
276
+ | flags_opt ieee_float { $$ = ndt_primitive($2, $1, ctx); if ($$ == NULL) YYABORT; }
277
+ | flags_opt COMPLEX_KIND { $$ = ndt_complex_kind($1, ctx); if ($$ == NULL) YYABORT; }
278
+ | flags_opt BCOMPLEX32 { $$ = ndt_primitive(BComplex32, $1, ctx); if ($$ == NULL) YYABORT; }
279
+ | flags_opt ieee_complex { $$ = ndt_primitive($2, $1, ctx); if ($$ == NULL) YYABORT; }
280
+ | flags_opt alias { $$ = ndt_from_alias($2, $1, ctx); if ($$ == NULL) YYABORT; }
281
+ | character { $$ = $1; }
282
+ | string { $$ = $1; }
283
+ | option_opt FIXED_STRING_KIND { $$ = ndt_fixed_string_kind($1, ctx); if ($$ == NULL) YYABORT; }
284
+ | fixed_string { $$ = $1; }
285
+ | bytes { $$ = $1; }
286
+ | option_opt FIXED_BYTES_KIND { $$ = ndt_fixed_bytes_kind($1, ctx); if ($$ == NULL) YYABORT; }
287
+ | fixed_bytes { $$ = $1; }
288
+ | categorical { $$ = $1; }
289
+ | ref { $$ = $1; }
273
290
 
274
291
  signed:
275
- endian_opt INT8 { $$ = ndt_primitive(Int8, $1, ctx); if ($$ == NULL) YYABORT; }
276
- | endian_opt INT16 { $$ = ndt_primitive(Int16, $1, ctx); if ($$ == NULL) YYABORT; }
277
- | endian_opt INT32 { $$ = ndt_primitive(Int32, $1, ctx); if ($$ == NULL) YYABORT; }
278
- | endian_opt INT64 { $$ = ndt_primitive(Int64, $1, ctx); if ($$ == NULL) YYABORT; }
292
+ INT8 { $$ = Int8; }
293
+ | INT16 { $$ = Int16; }
294
+ | INT32 { $$ = Int32; }
295
+ | INT64 { $$ = Int64; }
279
296
 
280
297
  unsigned:
281
- endian_opt UINT8 { $$ = ndt_primitive(Uint8, $1, ctx); if ($$ == NULL) YYABORT; }
282
- | endian_opt UINT16 { $$ = ndt_primitive(Uint16, $1, ctx); if ($$ == NULL) YYABORT; }
283
- | endian_opt UINT32 { $$ = ndt_primitive(Uint32, $1, ctx); if ($$ == NULL) YYABORT; }
284
- | endian_opt UINT64 { $$ = ndt_primitive(Uint64, $1, ctx); if ($$ == NULL) YYABORT; }
298
+ UINT8 { $$ = Uint8; }
299
+ | UINT16 { $$ = Uint16; }
300
+ | UINT32 { $$ = Uint32; }
301
+ | UINT64 { $$ = Uint64; }
285
302
 
286
303
  ieee_float:
287
- endian_opt FLOAT16 { $$ = ndt_primitive(Float16, $1, ctx); if ($$ == NULL) YYABORT; }
288
- | endian_opt FLOAT32 { $$ = ndt_primitive(Float32, $1, ctx); if ($$ == NULL) YYABORT; }
289
- | endian_opt FLOAT64 { $$ = ndt_primitive(Float64, $1, ctx); if ($$ == NULL) YYABORT; }
304
+ FLOAT16 { $$ = Float16; }
305
+ | FLOAT32 { $$ = Float32; }
306
+ | FLOAT64 { $$ = Float64; }
290
307
 
291
308
  ieee_complex:
292
- endian_opt COMPLEX32 { $$ = ndt_primitive(Complex32, $1, ctx); if ($$ == NULL) YYABORT; }
293
- | endian_opt COMPLEX64 { $$ = ndt_primitive(Complex64, $1, ctx); if ($$ == NULL) YYABORT; }
294
- | endian_opt COMPLEX128 { $$ = ndt_primitive(Complex128, $1, ctx); if ($$ == NULL) YYABORT; }
309
+ COMPLEX32 { $$ = Complex32; }
310
+ | COMPLEX64 { $$ = Complex64; }
311
+ | COMPLEX128 { $$ = Complex128; }
295
312
 
296
313
  alias:
297
314
  /* machine dependent */
298
- endian_opt INTPTR { $$ = ndt_from_alias(Intptr, $1, ctx); if ($$ == NULL) YYABORT; }
299
- | endian_opt UINTPTR { $$ = ndt_from_alias(Uintptr, $1, ctx); if ($$ == NULL) YYABORT; }
300
- | endian_opt SIZE { $$ = ndt_from_alias(Size, $1, ctx); if ($$ == NULL) YYABORT; }
315
+ INTPTR { $$ = Intptr; }
316
+ | UINTPTR { $$ = Uintptr; }
317
+ | SIZE { $$ = Size; }
301
318
 
302
319
  character:
303
- CHAR { $$ = ndt_char(Utf32, ctx); if ($$ == NULL) YYABORT; }
304
- | CHAR LPAREN encoding RPAREN { $$ = ndt_char($3, ctx); if ($$ == NULL) YYABORT; }
320
+ option_opt CHAR { $$ = ndt_char(Utf32, $1, ctx); if ($$ == NULL) YYABORT; }
321
+ | option_opt CHAR LPAREN encoding RPAREN { $$ = ndt_char($4, $1, ctx); if ($$ == NULL) YYABORT; }
305
322
 
306
323
  string:
307
- STRING { $$ = ndt_string(ctx); if ($$ == NULL) YYABORT; }
324
+ option_opt STRING { $$ = ndt_string($1, ctx); if ($$ == NULL) YYABORT; }
308
325
 
309
326
  fixed_string:
310
- FIXED_STRING LPAREN INTEGER RPAREN { $$ = mk_fixed_string($3, Utf8, ctx); if ($$ == NULL) YYABORT; }
311
- | FIXED_STRING LPAREN INTEGER COMMA encoding RPAREN { $$ = mk_fixed_string($3, $5, ctx); if ($$ == NULL) YYABORT; }
327
+ option_opt FIXED_STRING LPAREN INTEGER RPAREN { $$ = mk_fixed_string($4, Utf8, $1, ctx); if ($$ == NULL) YYABORT; }
328
+ | option_opt FIXED_STRING LPAREN INTEGER COMMA encoding RPAREN { $$ = mk_fixed_string($4, $6, $1, ctx); if ($$ == NULL) YYABORT; }
329
+
330
+ flags_opt:
331
+ option_opt endian_opt { $$ = $1 | $2; }
332
+
333
+ option_opt:
334
+ %empty { $$ = 0; }
335
+ | QUESTIONMARK { $$ = NDT_OPTION; }
312
336
 
313
337
  endian_opt:
314
338
  %empty { $$ = 0; }
@@ -321,17 +345,26 @@ encoding:
321
345
  STRINGLIT { $$ = encoding_from_string($1, ctx); if (ndt_err_occurred(ctx)) YYABORT; }
322
346
 
323
347
  bytes:
324
- BYTES arguments_opt { $$ = mk_bytes($2, ctx); if ($$ == NULL) YYABORT; }
348
+ option_opt BYTES arguments_opt { $$ = mk_bytes($3, $1, ctx); if ($$ == NULL) YYABORT; }
349
+
350
+ array_dimensions:
351
+ array { $$ = $1; }
352
+ | option_opt ARRAY ELLIPSIS OF datashape { $$ = mk_array_ellipsis($5, ctx); if ($$ == NULL) YYABORT; }
353
+ | option_opt ARRAY ELLIPSIS OF array { $$ = mk_array_ellipsis($5, ctx); if ($$ == NULL) YYABORT; }
354
+
355
+ array:
356
+ option_opt ARRAY OF datashape { $$ = mk_array($4, $1, ctx); if ($$ == NULL) YYABORT; }
357
+ | option_opt ARRAY OF array { $$ = mk_array($4, $1, ctx); if ($$ == NULL) YYABORT; }
325
358
 
326
359
  fixed_bytes:
327
- FIXED_BYTES LPAREN attribute_seq RPAREN { $$ = mk_fixed_bytes($3, ctx); if ($$ == NULL) YYABORT; }
360
+ option_opt FIXED_BYTES LPAREN attribute_seq RPAREN { $$ = mk_fixed_bytes($4, $1, ctx); if ($$ == NULL) YYABORT; }
328
361
 
329
362
  ref:
330
- REF LPAREN datashape RPAREN { $$ = ndt_ref($3, ctx); if ($$ == NULL) YYABORT; }
331
- | AMPERSAND datashape { $$ = ndt_ref($2, ctx); if ($$ == NULL) YYABORT; }
363
+ option_opt REF LPAREN datashape RPAREN { $$ = mk_ref($4, $1, ctx); if ($$ == NULL) YYABORT; }
364
+ | option_opt AMPERSAND datashape { $$ = mk_ref($3, $1, ctx); if ($$ == NULL) YYABORT; }
332
365
 
333
366
  categorical:
334
- CATEGORICAL LPAREN typed_value_seq RPAREN { $$ = mk_categorical($3, ctx); if ($$ == NULL) YYABORT; }
367
+ option_opt CATEGORICAL LPAREN typed_value_seq RPAREN { $$ = mk_categorical($4, $1, ctx); if ($$ == NULL) YYABORT; }
335
368
 
336
369
  typed_value_seq:
337
370
  typed_value { $$ = ndt_value_seq_new($1, ctx); if ($$ == NULL) YYABORT; }
@@ -353,9 +386,12 @@ comma_variadic_flag:
353
386
  | COMMA ELLIPSIS { $$ = Variadic; }
354
387
 
355
388
  tuple_type:
356
- LPAREN variadic_flag RPAREN { $$ = mk_tuple($2, NULL, NULL, ctx); if ($$ == NULL) YYABORT; }
357
- | LPAREN tuple_field_seq comma_variadic_flag RPAREN { $$ = mk_tuple($3, $2, NULL, ctx); if ($$ == NULL) YYABORT; }
358
- | LPAREN tuple_field_seq COMMA attribute_seq RPAREN { $$ = mk_tuple(Nonvariadic, $2, $4, ctx); if ($$ == NULL) YYABORT; }
389
+ LPAREN variadic_flag RPAREN { $$ = mk_tuple($2, NULL, NULL, false, ctx); if ($$ == NULL) YYABORT; }
390
+ | LPAREN tuple_field_seq comma_variadic_flag RPAREN { $$ = mk_tuple($3, $2, NULL, false, ctx); if ($$ == NULL) YYABORT; }
391
+ | LPAREN tuple_field_seq COMMA attribute_seq RPAREN { $$ = mk_tuple(Nonvariadic, $2, $4, false, ctx); if ($$ == NULL) YYABORT; }
392
+ | QUESTIONMARK LPAREN variadic_flag RPAREN { $$ = mk_tuple($3, NULL, NULL, true, ctx); if ($$ == NULL) YYABORT; }
393
+ | QUESTIONMARK LPAREN tuple_field_seq comma_variadic_flag RPAREN { $$ = mk_tuple($4, $3, NULL, true, ctx); if ($$ == NULL) YYABORT; }
394
+ | QUESTIONMARK LPAREN tuple_field_seq COMMA attribute_seq RPAREN { $$ = mk_tuple(Nonvariadic, $3, $5, true, ctx); if ($$ == NULL) YYABORT; }
359
395
 
360
396
  tuple_field_seq:
361
397
  tuple_field { $$ = ndt_field_seq_new($1, ctx); if ($$ == NULL) YYABORT; }
@@ -366,23 +402,39 @@ tuple_field:
366
402
  | datashape BAR attribute_seq BAR { $$ = mk_field(NULL, $1, $3, ctx); if ($$ == NULL) YYABORT; }
367
403
 
368
404
  record_type:
369
- LBRACE variadic_flag RBRACE { $$ = mk_record($2, NULL, NULL, ctx); if ($$ == NULL) YYABORT; }
370
- | LBRACE record_field_seq comma_variadic_flag RBRACE { $$ = mk_record($3, $2, NULL, ctx); if ($$ == NULL) YYABORT; }
371
- | LBRACE record_field_seq COMMA attribute_seq RBRACE { $$ = mk_record(Nonvariadic, $2, $4, ctx); if ($$ == NULL) YYABORT; }
405
+ LBRACE variadic_flag RBRACE { $$ = mk_record($2, NULL, NULL, false, ctx); if ($$ == NULL) YYABORT; }
406
+ | LBRACE record_field_seq comma_variadic_flag RBRACE { $$ = mk_record($3, $2, NULL, false, ctx); if ($$ == NULL) YYABORT; }
407
+ | LBRACE record_field_seq COMMA attribute_seq RBRACE { $$ = mk_record(Nonvariadic, $2, $4, false, ctx); if ($$ == NULL) YYABORT; }
408
+ | QUESTIONMARK LBRACE variadic_flag RBRACE { $$ = mk_record($3, NULL, NULL, true, ctx); if ($$ == NULL) YYABORT; }
409
+ | QUESTIONMARK LBRACE record_field_seq comma_variadic_flag RBRACE { $$ = mk_record($4, $3, NULL, true, ctx); if ($$ == NULL) YYABORT; }
410
+ | QUESTIONMARK LBRACE record_field_seq COMMA attribute_seq RBRACE { $$ = mk_record(Nonvariadic, $3, $5, true, ctx); if ($$ == NULL) YYABORT; }
372
411
 
373
412
  record_field_seq:
374
413
  record_field { $$ = ndt_field_seq_new($1, ctx); if ($$ == NULL) YYABORT; }
375
414
  | record_field_seq COMMA record_field { $$ = ndt_field_seq_append($1, $3, ctx); if ($$ == NULL) YYABORT; }
376
415
 
377
416
  record_field:
378
- record_field_name COLON datashape { $$ = mk_field($1, $3, NULL, ctx); if ($$ == NULL) YYABORT; }
379
- | record_field_name COLON datashape BAR attribute_seq BAR { $$ = mk_field($1, $3, $5, ctx); if ($$ == NULL) YYABORT; }
417
+ field_name_or_tag COLON datashape { $$ = mk_field($1, $3, NULL, ctx); if ($$ == NULL) YYABORT; }
418
+ | field_name_or_tag COLON datashape BAR attribute_seq BAR { $$ = mk_field($1, $3, $5, ctx); if ($$ == NULL) YYABORT; }
380
419
 
381
- record_field_name:
420
+ field_name_or_tag:
382
421
  NAME_LOWER { $$ = $1; if ($$ == NULL) YYABORT; }
383
422
  | NAME_UPPER { $$ = $1; if ($$ == NULL) YYABORT; }
384
423
  | NAME_OTHER { $$ = $1; if ($$ == NULL) YYABORT; }
385
424
 
425
+ union_type:
426
+ union_member_seq %prec BELOW_BAR { $$ = mk_union($1, false, ctx); if ($$ == NULL) YYABORT; }
427
+ | LBRACK union_member_seq RBRACK { $$ = mk_union($2, false, ctx); if ($$ == NULL) YYABORT; }
428
+ | QUESTIONMARK union_member_seq %prec BELOW_BAR { $$ = mk_union($2, true, ctx); if ($$ == NULL) YYABORT; }
429
+ | QUESTIONMARK LBRACK union_member_seq RBRACK { $$ = mk_union($3, true, ctx); if ($$ == NULL) YYABORT; }
430
+
431
+ union_member_seq:
432
+ union_member { $$ = ndt_field_seq_new($1, ctx); if ($$ == NULL) YYABORT; }
433
+ | union_member_seq BAR union_member { $$ = ndt_field_seq_append($1, $3, ctx); if ($$ == NULL) YYABORT; }
434
+
435
+ union_member:
436
+ field_name_or_tag OF datashape { $$ = mk_field($1, $3, NULL, ctx); if ($$ == NULL) YYABORT; }
437
+
386
438
  arguments_opt:
387
439
  %empty { $$ = NULL; }
388
440
  | LPAREN attribute_seq RPAREN { $$ = $2; if ($$ == NULL) YYABORT; }
@@ -400,8 +452,7 @@ untyped_value_seq:
400
452
  | untyped_value_seq COMMA untyped_value { $$ = ndt_string_seq_append($1, $3, ctx); if ($$ == NULL) YYABORT; }
401
453
 
402
454
  untyped_value:
403
- NAME_LOWER { $$ = $1; if ($$ == NULL) YYABORT; }
404
- | INTEGER { $$ = $1; if ($$ == NULL) YYABORT; }
455
+ INTEGER { $$ = $1; if ($$ == NULL) YYABORT; }
405
456
  | FLOATNUMBER { $$ = $1; if ($$ == NULL) YYABORT; }
406
457
  | STRINGLIT { $$ = $1; if ($$ == NULL) YYABORT; }
407
458
 
@@ -409,9 +460,9 @@ function_type:
409
460
  type_seq_or_void RARROW type_seq_or_void { $$ = mk_function($1, $3, ctx); if ($$ == NULL) YYABORT; }
410
461
 
411
462
  type_seq_or_void:
412
- type_seq { $$ = $1; if ($$ == NULL) YYABORT; }
463
+ type_seq { $$ = $1; }
413
464
  | VOID { $$ = ndt_type_seq_empty(ctx); if ($$ == NULL) YYABORT; }
414
465
 
415
466
  type_seq:
416
- datashape_with_ellipsis { $$ = ndt_type_seq_new($1, ctx); if ($$ == NULL) YYABORT; }
417
- | type_seq COMMA datashape_with_ellipsis { $$ = ndt_type_seq_append($1, $3, ctx); if ($$ == NULL) YYABORT; }
467
+ datashape_with_ellipsis { $$ = ndt_type_seq_new((ndt_t *)$1, ctx); if ($$ == NULL) YYABORT; }
468
+ | type_seq COMMA datashape_with_ellipsis { $$ = ndt_type_seq_append($1, (ndt_t *)$3, ctx); if ($$ == NULL) YYABORT; }