ndtypes 0.2.0dev5 → 0.2.0dev6

Sign up to get free protection for your applications and to get access to all the features.
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_BP_BPGRAMMAR_H_INCLUDED
34
38
  # define YY_NDT_BP_BPGRAMMAR_H_INCLUDED
35
39
  /* Debug traces. */
@@ -40,7 +44,7 @@
40
44
  extern int ndt_bpdebug;
41
45
  #endif
42
46
  /* "%code requires" blocks. */
43
- #line 292 "bpgrammar.y" /* yacc.c:1909 */
47
+ #line 302 "bpgrammar.y" /* yacc.c:1921 */
44
48
 
45
49
  #include <ctype.h>
46
50
  #include <assert.h>
@@ -51,7 +55,7 @@ extern int ndt_bpdebug;
51
55
  #define YY_TYPEDEF_YY_SCANNER_T
52
56
  typedef void * yyscan_t;
53
57
 
54
- #line 55 "bpgrammar.h" /* yacc.c:1909 */
58
+ #line 59 "bpgrammar.h" /* yacc.c:1921 */
55
59
 
56
60
  /* Token type. */
57
61
  #ifndef YYTOKENTYPE
@@ -86,9 +90,9 @@ extern int ndt_bpdebug;
86
90
 
87
91
  union YYSTYPE
88
92
  {
89
- #line 325 "bpgrammar.y" /* yacc.c:1909 */
93
+ #line 335 "bpgrammar.y" /* yacc.c:1921 */
90
94
 
91
- ndt_t *ndt;
95
+ const ndt_t *ndt;
92
96
  ndt_field_t *field;
93
97
  ndt_field_seq_t *field_seq;
94
98
  ndt_string_seq_t *string_seq;
@@ -97,7 +101,7 @@ union YYSTYPE
97
101
  unsigned char uchar;
98
102
  uint16_t uint16;
99
103
 
100
- #line 101 "bpgrammar.h" /* yacc.c:1909 */
104
+ #line 105 "bpgrammar.h" /* yacc.c:1921 */
101
105
  };
102
106
 
103
107
  typedef union YYSTYPE YYSTYPE;
@@ -121,14 +125,14 @@ struct YYLTYPE
121
125
 
122
126
 
123
127
 
124
- int ndt_bpparse (yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx);
128
+ int ndt_bpparse (yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx);
125
129
  /* "%code provides" blocks. */
126
- #line 303 "bpgrammar.y" /* yacc.c:1909 */
130
+ #line 313 "bpgrammar.y" /* yacc.c:1921 */
127
131
 
128
132
  #define YY_DECL extern int ndt_bplexfunc(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, ndt_context_t *ctx)
129
133
  extern int ndt_bplexfunc(YYSTYPE *, YYLTYPE *, yyscan_t, ndt_context_t *);
130
- void yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx, const char *msg);
134
+ void yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx, const char *msg);
131
135
 
132
- #line 133 "bpgrammar.h" /* yacc.c:1909 */
136
+ #line 137 "bpgrammar.h" /* yacc.c:1921 */
133
137
 
134
138
  #endif /* !YY_NDT_BP_BPGRAMMAR_H_INCLUDED */
@@ -37,7 +37,7 @@
37
37
 
38
38
 
39
39
  void
40
- yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx,
40
+ yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx,
41
41
  const char *msg)
42
42
  {
43
43
  (void)scanner;
@@ -67,13 +67,13 @@ add_uint16(uint16_t a, uint16_t b, ndt_context_t *ctx)
67
67
  return c;
68
68
  }
69
69
 
70
- static ndt_t *
70
+ static const ndt_t *
71
71
  primitive_native(char dtype, ndt_context_t *ctx)
72
72
  {
73
73
  switch (dtype) {
74
74
  case '?': return ndt_primitive(Bool, 0, ctx);
75
75
 
76
- case 'c': return ndt_char(Ascii, ctx);
76
+ case 'c': return ndt_char(Ascii, false, ctx);
77
77
  case 'b': return ndt_primitive(Int8, 0, ctx);
78
78
  case 'B': return ndt_primitive(Uint8, 0, ctx);
79
79
 
@@ -104,13 +104,13 @@ primitive_native(char dtype, ndt_context_t *ctx)
104
104
  }
105
105
  }
106
106
 
107
- static ndt_t *
107
+ static const ndt_t *
108
108
  primitive_fixed(char dtype, uint32_t flags, ndt_context_t *ctx)
109
109
  {
110
110
  switch (dtype) {
111
111
  case '?': return ndt_primitive(Bool, flags, ctx);
112
112
 
113
- case 'c': return ndt_char(Ascii, ctx);
113
+ case 'c': return ndt_char(Ascii, false, ctx);
114
114
  case 'b': return ndt_primitive(Int8, flags, ctx);
115
115
  case 'B': return ndt_primitive(Uint8, flags, ctx);
116
116
 
@@ -139,7 +139,7 @@ primitive_fixed(char dtype, uint32_t flags, ndt_context_t *ctx)
139
139
  }
140
140
  }
141
141
 
142
- static ndt_t *
142
+ static const ndt_t *
143
143
  make_dtype(char modifier, char dtype, ndt_context_t *ctx)
144
144
  {
145
145
  switch (modifier) {
@@ -160,7 +160,7 @@ make_dtype(char modifier, char dtype, ndt_context_t *ctx)
160
160
  }
161
161
  }
162
162
 
163
- static ndt_t *
163
+ static const ndt_t *
164
164
  make_fixed_bytes(char *v, ndt_context_t *ctx)
165
165
  {
166
166
  uint16_opt_t align = {None, 0};
@@ -180,13 +180,13 @@ make_fixed_bytes(char *v, ndt_context_t *ctx)
180
180
  return NULL;
181
181
  }
182
182
 
183
- return ndt_fixed_bytes(datasize, align, ctx);
183
+ return ndt_fixed_bytes(datasize, align, false, ctx);
184
184
  }
185
185
 
186
- static ndt_t *
187
- make_dimensions(ndt_string_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
186
+ static const ndt_t *
187
+ make_dimensions(ndt_string_seq_t *seq, const ndt_t *type, ndt_context_t *ctx)
188
188
  {
189
- ndt_t *t;
189
+ const ndt_t *t;
190
190
  int64_t shape;
191
191
  int64_t i;
192
192
 
@@ -194,18 +194,21 @@ make_dimensions(ndt_string_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
194
194
  ndt_err_format(ctx, NDT_ValueError,
195
195
  "number of dimensions must be between 1 and %d", NDT_MAX_DIM);
196
196
  ndt_string_seq_del(seq);
197
- ndt_del(type);
197
+ ndt_decref(type);
198
198
  return NULL;
199
199
  }
200
200
 
201
+
201
202
  for (i=seq->len-1, t=type; i>=0; i--, type=t) {
202
203
  shape = ndt_strtoll(seq->ptr[i], 0, INT_MAX, ctx);
203
204
  if (ndt_err_occurred(ctx)) {
204
205
  ndt_string_seq_del(seq);
206
+ ndt_decref(type);
205
207
  return NULL;
206
208
  }
207
209
 
208
210
  t = ndt_fixed_dim(type, shape, INT64_MAX, ctx);
211
+ ndt_decref(type);
209
212
  if (t == NULL) {
210
213
  ndt_string_seq_del(seq);
211
214
  return NULL;
@@ -218,27 +221,32 @@ make_dimensions(ndt_string_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
218
221
  }
219
222
 
220
223
  static ndt_field_t *
221
- make_field(char *name, ndt_t *type, uint16_t padding, ndt_context_t *ctx)
224
+ make_field(char *name, const ndt_t *type, uint16_t padding, ndt_context_t *ctx)
222
225
  {
223
226
  uint16_opt_t align = {None, 0};
224
227
  uint16_opt_t pack = {None, 0};
225
228
  uint16_opt_t pad = {Some, 0};
229
+ ndt_field_t *f;
226
230
 
227
231
  pad.Some = padding;
228
- return ndt_field(name, type, align, pack, pad, ctx);
232
+ f = ndt_field(name, type, align, pack, pad, ctx);
233
+ ndt_decref(type);
234
+ return f;
229
235
  }
230
236
 
231
- static ndt_t *
237
+ static const ndt_t *
232
238
  make_record(ndt_field_seq_t *fields, ndt_context_t *ctx)
233
239
  {
234
240
  uint16_opt_t align = {None, 0};
235
241
  uint16_opt_t pack = {None, 0};
236
- ndt_t *t;
242
+ const ndt_t *t;
237
243
  int64_t i;
238
244
 
239
245
  fields = ndt_field_seq_finalize(fields);
240
246
  if (fields == NULL) {
241
- return ndt_record(Nonvariadic, NULL, 0, align, pack, ctx);
247
+ t = ndt_record(Nonvariadic, NULL, 0, align, pack, false, ctx);
248
+ ndt_field_seq_del(fields);
249
+ return t;
242
250
  }
243
251
 
244
252
  assert(fields->len >= 1);
@@ -255,18 +263,19 @@ make_record(ndt_field_seq_t *fields, ndt_context_t *ctx)
255
263
  fields->ptr[i].Concrete.explicit_align = true;
256
264
  }
257
265
 
258
- t = ndt_record(Nonvariadic, fields->ptr, fields->len, align, pack, ctx);
259
- ndt_free(fields);
266
+ t = ndt_record(Nonvariadic, fields->ptr, fields->len, align, pack, false, ctx);
267
+ ndt_field_seq_del(fields);
260
268
 
261
269
  return t;
262
270
  }
263
271
 
264
272
  static ndt_type_seq_t *
265
- broadcast_seq_new(ndt_t *type, ndt_context_t *ctx)
273
+ broadcast_seq_new(const ndt_t *type, ndt_context_t *ctx)
266
274
  {
267
275
  ndt_t *t;
268
276
 
269
- t = ndt_ellipsis_dim(NULL, type, ctx);
277
+ t = (ndt_t *)ndt_ellipsis_dim(NULL, type, ctx);
278
+ ndt_decref(type);
270
279
  if (t == NULL) {
271
280
  return NULL;
272
281
  }
@@ -275,11 +284,12 @@ broadcast_seq_new(ndt_t *type, ndt_context_t *ctx)
275
284
  }
276
285
 
277
286
  static ndt_type_seq_t *
278
- broadcast_seq_append(ndt_type_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
287
+ broadcast_seq_append(ndt_type_seq_t *seq, const ndt_t *type, ndt_context_t *ctx)
279
288
  {
280
289
  ndt_t *t;
281
290
 
282
- t = ndt_ellipsis_dim(NULL, type, ctx);
291
+ t = (ndt_t *)ndt_ellipsis_dim(NULL, type, ctx);
292
+ ndt_decref(type);
283
293
  if (t == NULL) {
284
294
  ndt_type_seq_del(seq);
285
295
  return NULL;
@@ -303,12 +313,12 @@ broadcast_seq_append(ndt_type_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
303
313
  %code provides {
304
314
  #define YY_DECL extern int ndt_bplexfunc(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, ndt_context_t *ctx)
305
315
  extern int ndt_bplexfunc(YYSTYPE *, YYLTYPE *, yyscan_t, ndt_context_t *);
306
- void yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx, const char *msg);
316
+ void yyerror(YYLTYPE *loc, yyscan_t scanner, const ndt_t **ast, ndt_context_t *ctx, const char *msg);
307
317
  }
308
318
 
309
319
 
310
320
  %pure-parser
311
- %error-verbose
321
+ %define parse.error verbose
312
322
 
313
323
 
314
324
  %locations
@@ -320,10 +330,10 @@ broadcast_seq_append(ndt_type_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
320
330
  }
321
331
 
322
332
  %lex-param {yyscan_t scanner} {ndt_context_t *ctx}
323
- %parse-param {yyscan_t scanner} {ndt_t **ast} {ndt_context_t *ctx}
333
+ %parse-param {yyscan_t scanner} {const ndt_t **ast} {ndt_context_t *ctx}
324
334
 
325
335
  %union {
326
- ndt_t *ndt;
336
+ const ndt_t *ndt;
327
337
  ndt_field_t *field;
328
338
  ndt_field_seq_t *field_seq;
329
339
  ndt_string_seq_t *string_seq;
@@ -366,7 +376,7 @@ ERRTOKEN
366
376
 
367
377
  %token ENDMARKER 0 "end of file"
368
378
 
369
- %destructor { ndt_del($$); } <ndt>
379
+ %destructor { ndt_decref($$); } <ndt>
370
380
  %destructor { ndt_field_del($$); } <field>
371
381
  %destructor { ndt_field_seq_del($$); } <field_seq>
372
382
  %destructor { ndt_string_seq_del($$); } <string_seq>
@@ -601,15 +601,15 @@ struct yy_trans_info
601
601
  flex_int32_t yy_verify;
602
602
  flex_int32_t yy_nxt;
603
603
  };
604
- static const flex_int16_t yy_accept[62] =
604
+ static const flex_int16_t yy_accept[63] =
605
605
  { 0,
606
606
  0, 0, 0, 0, 45, 43, 41, 40, 40, 30,
607
607
  42, 43, 33, 34, 31, 43, 37, 37, 32, 28,
608
- 27, 29, 2, 26, 5, 21, 19, 20, 7, 9,
609
- 11, 15, 13, 23, 4, 3, 18, 16, 17, 6,
610
- 8, 10, 14, 12, 24, 22, 35, 36, 38, 39,
611
- 42, 0, 37, 37, 25, 37, 39, 0, 0, 1,
612
- 0
608
+ 27, 29, 2, 26, 5, 7, 9, 11, 15, 13,
609
+ 23, 43, 4, 3, 18, 16, 17, 6, 8, 10,
610
+ 14, 12, 24, 22, 35, 36, 38, 39, 42, 0,
611
+ 37, 37, 25, 37, 21, 19, 20, 39, 0, 0,
612
+ 1, 0
613
613
  } ;
614
614
 
615
615
  static const YY_CHAR yy_ec[256] =
@@ -620,14 +620,14 @@ static const YY_CHAR yy_ec[256] =
620
620
  1, 2, 5, 1, 6, 1, 7, 1, 1, 8,
621
621
  9, 1, 1, 10, 11, 1, 1, 12, 13, 13,
622
622
  13, 13, 13, 13, 13, 13, 13, 14, 1, 15,
623
- 16, 17, 18, 19, 20, 21, 20, 22, 23, 24,
624
- 20, 25, 26, 20, 20, 27, 20, 28, 20, 20,
625
- 29, 20, 20, 30, 20, 20, 20, 20, 20, 20,
626
- 1, 1, 1, 1, 31, 1, 20, 32, 33, 34,
627
-
628
- 35, 36, 20, 37, 38, 20, 20, 39, 20, 40,
629
- 41, 20, 42, 20, 43, 20, 20, 20, 20, 44,
630
- 20, 20, 45, 1, 46, 1, 1, 1, 1, 1,
623
+ 16, 17, 18, 19, 20, 21, 20, 20, 20, 20,
624
+ 20, 22, 23, 20, 20, 24, 20, 25, 20, 20,
625
+ 26, 20, 20, 27, 20, 20, 20, 20, 20, 28,
626
+ 1, 1, 1, 1, 29, 1, 20, 30, 31, 32,
627
+
628
+ 33, 34, 20, 35, 36, 20, 20, 37, 20, 38,
629
+ 39, 20, 40, 20, 41, 20, 20, 20, 20, 42,
630
+ 20, 20, 43, 1, 44, 1, 1, 1, 1, 1,
631
631
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
632
632
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
633
633
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -644,77 +644,77 @@ static const YY_CHAR yy_ec[256] =
644
644
  1, 1, 1, 1, 1
645
645
  } ;
646
646
 
647
- static const YY_CHAR yy_meta[47] =
647
+ static const YY_CHAR yy_meta[45] =
648
648
  { 0,
649
649
  1, 1, 2, 2, 1, 1, 1, 1, 1, 1,
650
650
  1, 3, 3, 1, 1, 1, 1, 1, 1, 3,
651
651
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
652
652
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
653
- 3, 3, 3, 3, 1, 1
653
+ 3, 3, 1, 1
654
654
  } ;
655
655
 
656
- static const flex_int16_t yy_base[64] =
656
+ static const flex_int16_t yy_base[65] =
657
657
  { 0,
658
- 0, 0, 46, 0, 111, 112, 112, 112, 112, 112,
659
- 0, 77, 112, 112, 112, 81, 97, 83, 112, 112,
660
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
661
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
662
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 0,
663
- 0, 67, 95, 87, 112, 89, 0, 72, 69, 112,
664
- 112, 102, 94
658
+ 0, 0, 44, 0, 110, 111, 111, 111, 111, 111,
659
+ 0, 78, 111, 111, 111, 77, 96, 79, 111, 111,
660
+ 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
661
+ 111, 63, 111, 111, 111, 111, 111, 111, 111, 111,
662
+ 111, 111, 111, 111, 111, 111, 111, 0, 0, 68,
663
+ 94, 86, 111, 88, 111, 111, 111, 0, 73, 70,
664
+ 111, 111, 101, 90
665
665
  } ;
666
666
 
667
- static const flex_int16_t yy_def[64] =
667
+ static const flex_int16_t yy_def[65] =
668
668
  { 0,
669
- 61, 1, 61, 3, 61, 61, 61, 61, 61, 61,
670
- 62, 61, 61, 61, 61, 61, 61, 61, 61, 61,
671
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
672
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
673
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 63,
674
- 62, 61, 61, 61, 61, 61, 63, 61, 61, 61,
675
- 0, 61, 61
669
+ 62, 1, 62, 3, 62, 62, 62, 62, 62, 62,
670
+ 63, 62, 62, 62, 62, 62, 62, 62, 62, 62,
671
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
672
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
673
+ 62, 62, 62, 62, 62, 62, 62, 64, 63, 62,
674
+ 62, 62, 62, 62, 62, 62, 62, 64, 62, 62,
675
+ 62, 0, 62, 62
676
676
  } ;
677
677
 
678
- static const flex_int16_t yy_nxt[159] =
678
+ static const flex_int16_t yy_nxt[156] =
679
679
  { 0,
680
680
  6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
681
681
  16, 17, 18, 19, 20, 21, 22, 23, 24, 6,
682
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
683
- 6, 35, 36, 37, 38, 39, 40, 41, 42, 43,
684
- 6, 44, 45, 46, 47, 48, 6, 7, 8, 9,
685
- 6, 11, 6, 6, 6, 6, 6, 6, 6, 49,
686
- 6, 6, 6, 6, 6, 50, 50, 50, 50, 50,
687
- 50, 50, 50, 50, 50, 50, 6, 50, 50, 50,
688
- 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
689
- 6, 6, 53, 54, 56, 56, 57, 55, 56, 56,
690
-
691
- 56, 56, 51, 60, 51, 59, 53, 58, 53, 52,
692
- 61, 5, 61, 61, 61, 61, 61, 61, 61, 61,
693
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
694
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
695
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
696
- 61, 61, 61, 61, 61, 61, 61, 61
682
+ 25, 26, 27, 28, 29, 30, 31, 32, 6, 33,
683
+ 34, 35, 36, 37, 38, 39, 40, 41, 6, 42,
684
+ 43, 44, 45, 46, 6, 7, 8, 9, 6, 11,
685
+ 6, 6, 6, 6, 6, 6, 6, 47, 6, 6,
686
+ 6, 6, 6, 48, 48, 48, 48, 48, 48, 48,
687
+ 48, 48, 6, 48, 48, 48, 48, 48, 48, 48,
688
+ 48, 48, 48, 48, 48, 48, 6, 6, 51, 52,
689
+ 54, 54, 58, 53, 55, 56, 57, 54, 54, 54,
690
+
691
+ 54, 49, 61, 49, 60, 51, 59, 51, 50, 62,
692
+ 5, 62, 62, 62, 62, 62, 62, 62, 62, 62,
693
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
694
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
695
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
696
+ 62, 62, 62, 62, 62
697
697
  } ;
698
698
 
699
- static const flex_int16_t yy_chk[159] =
699
+ static const flex_int16_t yy_chk[156] =
700
700
  { 0,
701
701
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
702
702
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
703
703
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
704
704
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705
- 1, 1, 1, 1, 1, 1, 3, 3, 3, 3,
705
+ 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
706
706
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
707
707
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
708
708
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
709
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
710
- 3, 3, 16, 16, 18, 18, 63, 16, 54, 54,
711
-
712
- 56, 56, 62, 59, 62, 58, 53, 52, 17, 12,
713
- 5, 61, 61, 61, 61, 61, 61, 61, 61, 61,
714
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
715
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
716
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
717
- 61, 61, 61, 61, 61, 61, 61, 61
709
+ 3, 3, 3, 3, 3, 3, 3, 3, 16, 16,
710
+ 18, 18, 64, 16, 32, 32, 32, 52, 52, 54,
711
+
712
+ 54, 63, 60, 63, 59, 51, 50, 17, 12, 5,
713
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
714
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
715
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
716
+ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
717
+ 62, 62, 62, 62, 62
718
718
  } ;
719
719
 
720
720
  /* Table of booleans, true if rule could match eol. */
@@ -1128,13 +1128,13 @@ yy_match:
1128
1128
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1129
1129
  {
1130
1130
  yy_current_state = (int) yy_def[yy_current_state];
1131
- if ( yy_current_state >= 62 )
1131
+ if ( yy_current_state >= 63 )
1132
1132
  yy_c = yy_meta[yy_c];
1133
1133
  }
1134
1134
  yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1135
1135
  ++yy_cp;
1136
1136
  }
1137
- while ( yy_current_state != 61 );
1137
+ while ( yy_current_state != 62 );
1138
1138
  yy_cp = yyg->yy_last_accepting_cpos;
1139
1139
  yy_current_state = yyg->yy_last_accepting_state;
1140
1140
 
@@ -1269,109 +1269,109 @@ YY_RULE_SETUP
1269
1269
  YY_BREAK
1270
1270
  case 19:
1271
1271
  YY_RULE_SETUP
1272
- #line 139 "bplexer.l"
1272
+ #line 140 "bplexer.l"
1273
1273
  { yylval->uchar = 'E'; return DTYPE; }
1274
1274
  YY_BREAK
1275
1275
  case 20:
1276
1276
  YY_RULE_SETUP
1277
- #line 140 "bplexer.l"
1277
+ #line 141 "bplexer.l"
1278
1278
  { yylval->uchar = 'F'; return DTYPE; }
1279
1279
  YY_BREAK
1280
1280
  case 21:
1281
1281
  YY_RULE_SETUP
1282
- #line 141 "bplexer.l"
1282
+ #line 142 "bplexer.l"
1283
1283
  { yylval->uchar = 'D'; return DTYPE; }
1284
1284
  YY_BREAK
1285
1285
  case 22:
1286
1286
  YY_RULE_SETUP
1287
- #line 143 "bplexer.l"
1287
+ #line 144 "bplexer.l"
1288
1288
  { return PAD; }
1289
1289
  YY_BREAK
1290
1290
  case 23:
1291
1291
  YY_RULE_SETUP
1292
- #line 144 "bplexer.l"
1292
+ #line 145 "bplexer.l"
1293
1293
  { return RECORD; }
1294
1294
  YY_BREAK
1295
1295
  case 24:
1296
1296
  YY_RULE_SETUP
1297
- #line 145 "bplexer.l"
1297
+ #line 146 "bplexer.l"
1298
1298
  { return BYTES; }
1299
1299
  YY_BREAK
1300
1300
  case 25:
1301
1301
  YY_RULE_SETUP
1302
- #line 147 "bplexer.l"
1302
+ #line 148 "bplexer.l"
1303
1303
  { return RARROW; }
1304
1304
  YY_BREAK
1305
1305
  case 26:
1306
1306
  YY_RULE_SETUP
1307
- #line 148 "bplexer.l"
1307
+ #line 149 "bplexer.l"
1308
1308
  { return AT; }
1309
1309
  YY_BREAK
1310
1310
  case 27:
1311
1311
  YY_RULE_SETUP
1312
- #line 149 "bplexer.l"
1312
+ #line 150 "bplexer.l"
1313
1313
  { return EQUAL; }
1314
1314
  YY_BREAK
1315
1315
  case 28:
1316
1316
  YY_RULE_SETUP
1317
- #line 150 "bplexer.l"
1317
+ #line 151 "bplexer.l"
1318
1318
  { return LESS; }
1319
1319
  YY_BREAK
1320
1320
  case 29:
1321
1321
  YY_RULE_SETUP
1322
- #line 151 "bplexer.l"
1322
+ #line 152 "bplexer.l"
1323
1323
  { return GREATER; }
1324
1324
  YY_BREAK
1325
1325
  case 30:
1326
1326
  YY_RULE_SETUP
1327
- #line 152 "bplexer.l"
1327
+ #line 153 "bplexer.l"
1328
1328
  { return BANG; }
1329
1329
  YY_BREAK
1330
1330
  case 31:
1331
1331
  YY_RULE_SETUP
1332
- #line 153 "bplexer.l"
1332
+ #line 154 "bplexer.l"
1333
1333
  { return COMMA; }
1334
1334
  YY_BREAK
1335
1335
  case 32:
1336
1336
  YY_RULE_SETUP
1337
- #line 154 "bplexer.l"
1337
+ #line 155 "bplexer.l"
1338
1338
  { BEGIN(FIELDNAME); return COLON; }
1339
1339
  YY_BREAK
1340
1340
  case 33:
1341
1341
  YY_RULE_SETUP
1342
- #line 155 "bplexer.l"
1342
+ #line 156 "bplexer.l"
1343
1343
  { return LPAREN; }
1344
1344
  YY_BREAK
1345
1345
  case 34:
1346
1346
  YY_RULE_SETUP
1347
- #line 156 "bplexer.l"
1347
+ #line 157 "bplexer.l"
1348
1348
  { return RPAREN; }
1349
1349
  YY_BREAK
1350
1350
  case 35:
1351
1351
  YY_RULE_SETUP
1352
- #line 157 "bplexer.l"
1352
+ #line 158 "bplexer.l"
1353
1353
  { return LBRACE; }
1354
1354
  YY_BREAK
1355
1355
  case 36:
1356
1356
  YY_RULE_SETUP
1357
- #line 158 "bplexer.l"
1357
+ #line 159 "bplexer.l"
1358
1358
  { return RBRACE; }
1359
1359
  YY_BREAK
1360
1360
  case 37:
1361
1361
  YY_RULE_SETUP
1362
- #line 160 "bplexer.l"
1362
+ #line 161 "bplexer.l"
1363
1363
  { yylval->string = ndt_strdup(yytext, ctx); if (yylval->string == NULL) return ERRTOKEN; return INTEGER; }
1364
1364
  YY_BREAK
1365
1365
 
1366
1366
 
1367
1367
  case 38:
1368
1368
  YY_RULE_SETUP
1369
- #line 164 "bplexer.l"
1369
+ #line 165 "bplexer.l"
1370
1370
  { BEGIN(INITIAL); return COLON; }
1371
1371
  YY_BREAK
1372
1372
  case 39:
1373
1373
  YY_RULE_SETUP
1374
- #line 165 "bplexer.l"
1374
+ #line 166 "bplexer.l"
1375
1375
  { yylval->string = ndt_strdup(yytext, ctx); if (yylval->string == NULL) return ERRTOKEN; return NAME; }
1376
1376
  YY_BREAK
1377
1377
 
@@ -1379,28 +1379,28 @@ YY_RULE_SETUP
1379
1379
  case 40:
1380
1380
  /* rule 40 can match eol */
1381
1381
  YY_RULE_SETUP
1382
- #line 169 "bplexer.l"
1382
+ #line 170 "bplexer.l"
1383
1383
  { yycolumn = 1; }
1384
1384
  YY_BREAK
1385
1385
  case 41:
1386
1386
  YY_RULE_SETUP
1387
- #line 170 "bplexer.l"
1387
+ #line 171 "bplexer.l"
1388
1388
  {} /* ignore */
1389
1389
  YY_BREAK
1390
1390
  case 42:
1391
1391
  YY_RULE_SETUP
1392
- #line 171 "bplexer.l"
1392
+ #line 172 "bplexer.l"
1393
1393
  {} /* ignore */
1394
1394
  YY_BREAK
1395
1395
  case 43:
1396
1396
  YY_RULE_SETUP
1397
- #line 172 "bplexer.l"
1397
+ #line 173 "bplexer.l"
1398
1398
  { return ERRTOKEN; }
1399
1399
  YY_BREAK
1400
1400
 
1401
1401
  case 44:
1402
1402
  YY_RULE_SETUP
1403
- #line 176 "bplexer.l"
1403
+ #line 177 "bplexer.l"
1404
1404
  YY_FATAL_ERROR( "flex scanner jammed" );
1405
1405
  YY_BREAK
1406
1406
  #line 1406 "bplexer.c"
@@ -1704,7 +1704,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
1704
1704
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1705
1705
  {
1706
1706
  yy_current_state = (int) yy_def[yy_current_state];
1707
- if ( yy_current_state >= 62 )
1707
+ if ( yy_current_state >= 63 )
1708
1708
  yy_c = yy_meta[yy_c];
1709
1709
  }
1710
1710
  yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1733,11 +1733,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
1733
1733
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1734
1734
  {
1735
1735
  yy_current_state = (int) yy_def[yy_current_state];
1736
- if ( yy_current_state >= 62 )
1736
+ if ( yy_current_state >= 63 )
1737
1737
  yy_c = yy_meta[yy_c];
1738
1738
  }
1739
1739
  yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1740
- yy_is_jam = (yy_current_state == 61);
1740
+ yy_is_jam = (yy_current_state == 62);
1741
1741
 
1742
1742
  (void)yyg;
1743
1743
  return yy_is_jam ? 0 : yy_current_state;
@@ -2538,6 +2538,6 @@ static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2538
2538
 
2539
2539
  #define YYTABLES_NAME "yytables"
2540
2540
 
2541
- #line 176 "bplexer.l"
2541
+ #line 177 "bplexer.l"
2542
2542
 
2543
2543