ndtypes 0.2.0dev4

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 (139) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +50 -0
  3. data/Gemfile +2 -0
  4. data/History.md +0 -0
  5. data/README.md +19 -0
  6. data/Rakefile +125 -0
  7. data/ext/ruby_ndtypes/extconf.rb +55 -0
  8. data/ext/ruby_ndtypes/gc_guard.c +36 -0
  9. data/ext/ruby_ndtypes/gc_guard.h +12 -0
  10. data/ext/ruby_ndtypes/ndtypes/AUTHORS.txt +5 -0
  11. data/ext/ruby_ndtypes/ndtypes/INSTALL.txt +101 -0
  12. data/ext/ruby_ndtypes/ndtypes/LICENSE.txt +29 -0
  13. data/ext/ruby_ndtypes/ndtypes/MANIFEST.in +3 -0
  14. data/ext/ruby_ndtypes/ndtypes/Makefile.in +87 -0
  15. data/ext/ruby_ndtypes/ndtypes/README.rst +47 -0
  16. data/ext/ruby_ndtypes/ndtypes/config.guess +1530 -0
  17. data/ext/ruby_ndtypes/ndtypes/config.h.in +67 -0
  18. data/ext/ruby_ndtypes/ndtypes/config.sub +1782 -0
  19. data/ext/ruby_ndtypes/ndtypes/configure +5260 -0
  20. data/ext/ruby_ndtypes/ndtypes/configure.ac +161 -0
  21. data/ext/ruby_ndtypes/ndtypes/doc/Makefile +14 -0
  22. data/ext/ruby_ndtypes/ndtypes/doc/_static/copybutton.js +66 -0
  23. data/ext/ruby_ndtypes/ndtypes/doc/conf.py +26 -0
  24. data/ext/ruby_ndtypes/ndtypes/doc/grammar/grammar.rst +27 -0
  25. data/ext/ruby_ndtypes/ndtypes/doc/index.rst +56 -0
  26. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/context.rst +131 -0
  27. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/encodings.rst +68 -0
  28. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/fields-values.rst +175 -0
  29. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/functions.rst +72 -0
  30. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/index.rst +43 -0
  31. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/init.rst +48 -0
  32. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/io.rst +100 -0
  33. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/memory.rst +124 -0
  34. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/predicates.rst +110 -0
  35. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/typedef.rst +31 -0
  36. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/types.rst +594 -0
  37. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/util.rst +166 -0
  38. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/buffer-protocol.rst +27 -0
  39. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/index.rst +21 -0
  40. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/pattern-matching.rst +330 -0
  41. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/quickstart.rst +144 -0
  42. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/types.rst +544 -0
  43. data/ext/ruby_ndtypes/ndtypes/doc/releases/index.rst +35 -0
  44. data/ext/ruby_ndtypes/ndtypes/install-sh +527 -0
  45. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.in +271 -0
  46. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.vc +269 -0
  47. data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.c +230 -0
  48. data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.c +268 -0
  49. data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.h +109 -0
  50. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile.in +73 -0
  51. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile.vc +70 -0
  52. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/README.txt +16 -0
  53. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.c +2179 -0
  54. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.h +134 -0
  55. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.y +428 -0
  56. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.c +2543 -0
  57. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.h +735 -0
  58. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.l +176 -0
  59. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.c +543 -0
  60. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.c +110 -0
  61. data/ext/ruby_ndtypes/ndtypes/libndtypes/context.c +228 -0
  62. data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.c +634 -0
  63. data/ext/ruby_ndtypes/ndtypes/libndtypes/encodings.c +116 -0
  64. data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.c +288 -0
  65. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +3067 -0
  66. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.h +180 -0
  67. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +417 -0
  68. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +1658 -0
  69. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.c +2773 -0
  70. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.h +734 -0
  71. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.l +222 -0
  72. data/ext/ruby_ndtypes/ndtypes/libndtypes/match.c +1132 -0
  73. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.c +2323 -0
  74. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h.in +893 -0
  75. data/ext/ruby_ndtypes/ndtypes/libndtypes/overflow.h +161 -0
  76. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.c +473 -0
  77. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.h +92 -0
  78. data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.c +246 -0
  79. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.c +269 -0
  80. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.h +197 -0
  81. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile.in +48 -0
  82. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile.vc +46 -0
  83. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.c +1007 -0
  84. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.c +442 -0
  85. data/ext/ruby_ndtypes/ndtypes/libndtypes/slice.h +42 -0
  86. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.c +238 -0
  87. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.h +50 -0
  88. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.c +371 -0
  89. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.h +100 -0
  90. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.in +55 -0
  91. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.vc +45 -0
  92. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/alloc_fail.c +82 -0
  93. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/alloc_fail.h +49 -0
  94. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/runtest.c +1657 -0
  95. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test.h +85 -0
  96. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_array.c +115 -0
  97. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_buffer.c +137 -0
  98. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_indent.c +201 -0
  99. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +2397 -0
  100. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_numba.c +57 -0
  101. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +349 -0
  102. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +27839 -0
  103. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +350 -0
  104. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_record.c +231 -0
  105. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +375 -0
  106. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typedef.c +65 -0
  107. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/valgrind.supp +30 -0
  108. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/bench.c +79 -0
  109. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/indent.c +94 -0
  110. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/print_ast.c +96 -0
  111. data/ext/ruby_ndtypes/ndtypes/libndtypes/util.c +474 -0
  112. data/ext/ruby_ndtypes/ndtypes/libndtypes/values.c +228 -0
  113. data/ext/ruby_ndtypes/ndtypes/python/bench.py +49 -0
  114. data/ext/ruby_ndtypes/ndtypes/python/ndt_randtype.py +409 -0
  115. data/ext/ruby_ndtypes/ndtypes/python/ndt_support.py +14 -0
  116. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/__init__.py +70 -0
  117. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +1332 -0
  118. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/docstrings.h +319 -0
  119. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/pyndtypes.h +154 -0
  120. data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +1977 -0
  121. data/ext/ruby_ndtypes/ndtypes/setup.py +288 -0
  122. data/ext/ruby_ndtypes/ndtypes/vcbuild/INSTALL.txt +41 -0
  123. data/ext/ruby_ndtypes/ndtypes/vcbuild/runtest32.bat +15 -0
  124. data/ext/ruby_ndtypes/ndtypes/vcbuild/runtest64.bat +13 -0
  125. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcbuild32.bat +38 -0
  126. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcbuild64.bat +38 -0
  127. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcclean.bat +13 -0
  128. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcdistclean.bat +14 -0
  129. data/ext/ruby_ndtypes/ruby_ndtypes.c +1003 -0
  130. data/ext/ruby_ndtypes/ruby_ndtypes.h +37 -0
  131. data/ext/ruby_ndtypes/ruby_ndtypes_internal.h +28 -0
  132. data/lib/ndtypes.rb +45 -0
  133. data/lib/ndtypes/errors.rb +2 -0
  134. data/lib/ndtypes/version.rb +6 -0
  135. data/ndtypes.gemspec +47 -0
  136. data/spec/gc_table_spec.rb +10 -0
  137. data/spec/ndtypes_spec.rb +289 -0
  138. data/spec/spec_helper.rb +241 -0
  139. metadata +242 -0
@@ -0,0 +1,109 @@
1
+ /*
2
+ * BSD 3-Clause License
3
+ *
4
+ * Copyright (c) 2017-2018, plures
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * 3. Neither the name of the copyright holder nor the names of its
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+
34
+ #ifndef ATTR_H
35
+ #define ATTR_H
36
+
37
+ #include <stdio.h>
38
+ #include <string.h>
39
+ #include <stdarg.h>
40
+ #include "ndtypes.h"
41
+ #include "seq.h"
42
+
43
+
44
+ #define MAX_ATTR 8
45
+
46
+ enum ndt_attr {
47
+ AttrBool,
48
+ AttrChar,
49
+ AttrInt8,
50
+ AttrInt16,
51
+ AttrInt32,
52
+ AttrInt64,
53
+ AttrUint8,
54
+ AttrUint16,
55
+ AttrUint32,
56
+ AttrUint64,
57
+ AttrSize,
58
+ AttrFloat32,
59
+ AttrFloat64,
60
+ AttrString,
61
+ AttrInt32List,
62
+ AttrCharOpt,
63
+ AttrInt64Opt,
64
+ AttrUint16Opt
65
+ };
66
+
67
+ enum ndt_attr_tag {
68
+ AttrValue,
69
+ AttrList
70
+ };
71
+
72
+ /* Attribute: name=value or name=[value, value, ...]. */
73
+ typedef struct {
74
+ enum ndt_attr_tag tag;
75
+ char *name;
76
+ union {
77
+ char *AttrValue;
78
+ struct {
79
+ int64_t len;
80
+ char **items;
81
+ } AttrList;
82
+ };
83
+ } ndt_attr_t;
84
+
85
+ typedef struct {
86
+ const int min;
87
+ const int max;
88
+ const char *names[MAX_ATTR];
89
+ const enum ndt_attr tags[MAX_ATTR];
90
+ } attr_spec;
91
+
92
+ typedef struct {
93
+ int64_t len;
94
+ int64_t reserved;
95
+ ndt_attr_t *ptr;
96
+ } ndt_attr_seq_t;
97
+
98
+ void ndt_attr_del(ndt_attr_t *attr);
99
+ void ndt_attr_array_del(ndt_attr_t *attr, int64_t nattr);
100
+
101
+ ndt_attr_seq_t *ndt_attr_seq_new(ndt_attr_t *, ndt_context_t *ctx);
102
+ void ndt_attr_seq_del(ndt_attr_seq_t *);
103
+ ndt_attr_seq_t *ndt_attr_seq_append(ndt_attr_seq_t *, ndt_attr_t *, ndt_context_t *ctx);
104
+ ndt_attr_seq_t *ndt_attr_seq_finalize(ndt_attr_seq_t *);
105
+
106
+ int ndt_parse_attr(const attr_spec *spec, ndt_context_t *ctx, const ndt_attr_seq_t *seq, ...);
107
+
108
+
109
+ #endif
@@ -0,0 +1,73 @@
1
+
2
+ CC = @CC@
3
+ LD = @LD@
4
+
5
+ CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@
6
+ NDT_CFLAGS = $(strip $(CONFIGURE_CFLAGS) $(CFLAGS))
7
+ NDT_CFLAGS_SHARED = $(NDT_CFLAGS) -fPIC
8
+
9
+ CONFIGURE_COV_CFLAGS = @CONFIGURE_COV_CFLAGS@
10
+ ifeq ($(MAKECMDGOALS), coverage)
11
+ NDT_CFLAGS = $(strip $(CONFIGURE_COV_CFLAGS) $(CFLAGS))
12
+ endif
13
+
14
+
15
+ OBJS = bpgrammar.o bplexer.o import.o export.o
16
+ SHARED_OBJS = .objs/bpgrammar.o .objs/bplexer.o .objs/import.o .objs/export.o
17
+
18
+
19
+ default: $(OBJS) $(SHARED_OBJS)
20
+
21
+
22
+ bpgrammar.o:\
23
+ Makefile bpgrammar.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
24
+ $(CC) $(NDT_CFLAGS) -c bpgrammar.c
25
+
26
+ .objs/bpgrammar.o:\
27
+ Makefile bpgrammar.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
28
+ $(CC) $(NDT_CFLAGS_SHARED) -c bpgrammar.c -o .objs/bpgrammar.o
29
+
30
+ bplexer.o:\
31
+ Makefile bplexer.c bpgrammar.h bplexer.h
32
+ $(CC) $(NDT_CFLAGS) -c bplexer.c
33
+
34
+ .objs/bplexer.o:\
35
+ Makefile bplexer.c bpgrammar.h bplexer.h
36
+ $(CC) $(NDT_CFLAGS_SHARED) -c bplexer.c -o .objs/bplexer.o
37
+
38
+ import.o:\
39
+ Makefile import.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
40
+ $(CC) $(NDT_CFLAGS) -c import.c
41
+
42
+ .objs/import.o:\
43
+ Makefile import.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
44
+ $(CC) $(NDT_CFLAGS_SHARED) -c import.c -o .objs/import.o
45
+
46
+ export.o:\
47
+ Makefile export.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
48
+ $(CC) $(NDT_CFLAGS) -c export.c
49
+
50
+ .objs/export.o:\
51
+ Makefile export.c bpgrammar.h bplexer.h ../ndtypes.h ../seq.h
52
+ $(CC) $(NDT_CFLAGS_SHARED) -c export.c -o .objs/export.o
53
+
54
+
55
+ # Without these, GNU make automatically builds the parser.
56
+ %.c: %.y
57
+ %.c: %.l
58
+
59
+ parser: FORCE
60
+ bison -Wall -o bpgrammar.c -pndt_bp --defines=bpgrammar.h bpgrammar.y
61
+ flex -o bplexer.c -Pndt_bp --header-file=bplexer.h bplexer.l
62
+
63
+
64
+ FORCE:
65
+
66
+ clean: FORCE
67
+ rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
68
+ cd .objs && rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
69
+
70
+ distclean: clean
71
+ rm -f Makefile
72
+
73
+
@@ -0,0 +1,70 @@
1
+
2
+ SRCDIR = ..
3
+
4
+ OPT = /MT /Ox /GS /EHsc
5
+ OPT_SHARED = /DNDT_EXPORT /MD /Ox /GS /EHsc /Fo.objs^\
6
+
7
+ COMMON_CFLAGS = -I$(SRCDIR) /nologo /W4 /wd4200 /wd4201 /wd4204
8
+ COMMON_CFLAGS_FOR_GENERATED = -I$(SRCDIR) /nologo /W4 /wd4200 /wd4201 /wd4244 /wd4267 /wd4702 /wd4127 /DYY_NO_UNISTD_H=1 /D__STDC_VERSION__=199901L
9
+ COMMON_CFLAGS_FOR_PARSER = -I$(SRCDIR) /nologo /W4 /wd4200 /wd4201 /wd4090 /nologo /DYY_NO_UNISTD_H=1
10
+
11
+ CFLAGS = $(COMMON_CFLAGS) $(OPT)
12
+ CFLAGS_SHARED = $(COMMON_CFLAGS) $(OPT_SHARED)
13
+
14
+ CFLAGS_FOR_GENERATED = $(COMMON_CFLAGS_FOR_GENERATED) $(OPT)
15
+ CFLAGS_FOR_GENERATED_SHARED = $(COMMON_CFLAGS_FOR_GENERATED) $(OPT_SHARED)
16
+
17
+ CFLAGS_FOR_PARSER = $(COMMON_CFLAGS_FOR_PARSER) $(OPT)
18
+ CFLAGS_FOR_PARSER_SHARED = $(COMMON_CFLAGS_FOR_PARSER) $(OPT_SHARED)
19
+
20
+
21
+ OBJS = bpgrammar.obj bplexer.obj import.obj export.obj
22
+ SHARED_OBJS = .objs\bpgrammar.obj .objs\bplexer.obj .objs\import.obj .objs\export.obj
23
+
24
+
25
+ default: $(OBJS) $(SHARED_OBJS)
26
+
27
+
28
+ bpgrammar.obj:\
29
+ Makefile bpgrammar.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
30
+ $(CC) $(CFLAGS_FOR_GENERATED) -c bpgrammar.c
31
+
32
+ .objs\bpgrammar.obj:\
33
+ Makefile bpgrammar.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
34
+ $(CC) $(CFLAGS_FOR_GENERATED_SHARED) -c bpgrammar.c
35
+
36
+ bplexer.obj:\
37
+ Makefile bplexer.c bpgrammar.h bplexer.h
38
+ $(CC) $(CFLAGS_FOR_GENERATED) -c bplexer.c
39
+
40
+ .objs\bplexer.obj:\
41
+ Makefile bplexer.c bpgrammar.h bplexer.h
42
+ $(CC) $(CFLAGS_FOR_GENERATED_SHARED) -c bplexer.c
43
+
44
+ import.obj:\
45
+ Makefile import.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
46
+ $(CC) $(CFLAGS_FOR_PARSER) -c import.c
47
+
48
+ .objs\import.obj:\
49
+ Makefile import.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
50
+ $(CC) $(CFLAGS_FOR_PARSER_SHARED) -c import.c
51
+
52
+ export.obj:\
53
+ Makefile export.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
54
+ $(CC) $(CFLAGS_FOR_PARSER) -c export.c
55
+
56
+ .objs\export.obj:\
57
+ Makefile export.c bpgrammar.h bplexer.h ..\ndtypes.h ..\seq.h
58
+ $(CC) $(CFLAGS_FOR_PARSER_SHARED) -c export.c
59
+
60
+
61
+ FORCE:
62
+
63
+ clean: FORCE
64
+ del /q /f *.exe *.obj *.lib *.dll *.exp *.manifest 2>NUL
65
+ cd .objs && del /q /f *.obj 2>NUL
66
+
67
+ distclean: clean
68
+ del Makefile 2>NUL
69
+
70
+
@@ -0,0 +1,16 @@
1
+
2
+
3
+ Support for translating various data description formats to datashape.
4
+ ======================================================================
5
+
6
+
7
+ PEP-3118 (buffer protocol)
8
+ --------------------------
9
+
10
+ bpgrammar.y
11
+ bplexer.l
12
+ import.c
13
+
14
+
15
+
16
+
@@ -0,0 +1,2179 @@
1
+ /* A Bison parser, made by GNU Bison 3.0.4. */
2
+
3
+ /* Bison implementation for Yacc-like parsers in C
4
+
5
+ Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
+
20
+ /* As a special exception, you may create a larger work that contains
21
+ part or all of the Bison parser skeleton and distribute that work
22
+ under terms of your choice, so long as that work isn't itself a
23
+ parser generator using the skeleton or a modified version thereof
24
+ as a parser skeleton. Alternatively, if you modify or redistribute
25
+ the parser skeleton itself, you may (at your option) remove this
26
+ special exception, which will cause the skeleton and the resulting
27
+ Bison output files to be licensed under the GNU General Public
28
+ License without this special exception.
29
+
30
+ This special exception was added by the Free Software Foundation in
31
+ version 2.2 of Bison. */
32
+
33
+ /* C LALR(1) parser skeleton written by Richard Stallman, by
34
+ simplifying the original so-called "semantic" parser. */
35
+
36
+ /* All symbols defined below should begin with yy or YY, to avoid
37
+ infringing on user name space. This should be done even for local
38
+ variables, as they might otherwise be expanded by user macros.
39
+ There are some unavoidable exceptions within include files to
40
+ define necessary library symbols; they are noted "INFRINGES ON
41
+ USER NAME SPACE" below. */
42
+
43
+ /* Identify Bison output. */
44
+ #define YYBISON 1
45
+
46
+ /* Bison version. */
47
+ #define YYBISON_VERSION "3.0.4"
48
+
49
+ /* Skeleton name. */
50
+ #define YYSKELETON_NAME "yacc.c"
51
+
52
+ /* Pure parsers. */
53
+ #define YYPURE 1
54
+
55
+ /* Push parsers. */
56
+ #define YYPUSH 0
57
+
58
+ /* Pull parsers. */
59
+ #define YYPULL 1
60
+
61
+
62
+ /* Substitute the variable and function names. */
63
+ #define yyparse ndt_bpparse
64
+ #define yylex ndt_bplex
65
+ #define yyerror ndt_bperror
66
+ #define yydebug ndt_bpdebug
67
+ #define yynerrs ndt_bpnerrs
68
+
69
+
70
+ /* Copy the first part of user declarations. */
71
+ #line 1 "bpgrammar.y" /* yacc.c:339 */
72
+
73
+ /*
74
+ * BSD 3-Clause License
75
+ *
76
+ * Copyright (c) 2017-2018, plures
77
+ * All rights reserved.
78
+ *
79
+ * Redistribution and use in source and binary forms, with or without
80
+ * modification, are permitted provided that the following conditions are met:
81
+ *
82
+ * 1. Redistributions of source code must retain the above copyright notice,
83
+ * this list of conditions and the following disclaimer.
84
+ *
85
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
86
+ * this list of conditions and the following disclaimer in the documentation
87
+ * and/or other materials provided with the distribution.
88
+ *
89
+ * 3. Neither the name of the copyright holder nor the names of its
90
+ * contributors may be used to endorse or promote products derived from
91
+ * this software without specific prior written permission.
92
+ *
93
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
94
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
95
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
97
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
98
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
99
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
100
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
101
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
102
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103
+ */
104
+
105
+
106
+ #include "bpgrammar.h"
107
+ #include "bplexer.h"
108
+
109
+
110
+ void
111
+ yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx,
112
+ const char *msg)
113
+ {
114
+ (void)scanner;
115
+ (void)ast;
116
+
117
+ ndt_err_format(ctx, NDT_ParseError, "%d:%d: %s\n", loc->first_line,
118
+ loc->first_column, msg);
119
+ }
120
+
121
+ int
122
+ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
123
+ {
124
+ return ndt_bplexfunc(val, loc, scanner, ctx);
125
+ }
126
+
127
+ static uint16_t
128
+ add_uint16(uint16_t a, uint16_t b, ndt_context_t *ctx)
129
+ {
130
+ bool overflow = 0;
131
+ uint16_t c = ADDu16(a, b, &overflow);
132
+
133
+ if (overflow) {
134
+ ndt_err_format(ctx, NDT_ValueError, "overflow while adding uint16");
135
+ return UINT16_MAX;
136
+ }
137
+
138
+ return c;
139
+ }
140
+
141
+ static ndt_t *
142
+ primitive_native(char dtype, ndt_context_t *ctx)
143
+ {
144
+ switch (dtype) {
145
+ case '?': return ndt_primitive(Bool, 0, ctx);
146
+
147
+ case 'c': return ndt_char(Ascii, ctx);
148
+ case 'b': return ndt_primitive(Int8, 0, ctx);
149
+ case 'B': return ndt_primitive(Uint8, 0, ctx);
150
+
151
+ case 'h': return ndt_signed(sizeof(short), 0, ctx);
152
+ case 'i': return ndt_signed(sizeof(int), 0, ctx);
153
+ case 'l': return ndt_signed(sizeof(long), 0, ctx);
154
+ case 'q': return ndt_signed(sizeof(long long), 0, ctx);
155
+ case 'n': return ndt_signed(sizeof(size_t), 0, ctx);
156
+
157
+ case 'H': return ndt_unsigned(sizeof(unsigned short), 0, ctx);
158
+ case 'I': return ndt_unsigned(sizeof(unsigned int), 0, ctx);
159
+ case 'L': return ndt_unsigned(sizeof(unsigned long), 0, ctx);
160
+ case 'Q': return ndt_unsigned(sizeof(unsigned long long), 0, ctx);
161
+ case 'N': return ndt_unsigned(sizeof(size_t), 0, ctx);
162
+
163
+ case 'e': return ndt_primitive(Float16, 0, ctx);
164
+ case 'f': return ndt_primitive(Float32, 0, ctx);
165
+ case 'd': return ndt_primitive(Float64, 0, ctx);
166
+
167
+ case 'E': return ndt_primitive(Complex32, 0, ctx);
168
+ case 'F': return ndt_primitive(Complex64, 0, ctx);
169
+ case 'D': return ndt_primitive(Complex128, 0, ctx);
170
+
171
+ default:
172
+ ndt_err_format(ctx, NDT_ValueError,
173
+ "invalid or unsupported dtype '%c'", dtype);
174
+ return NULL;
175
+ }
176
+ }
177
+
178
+ static ndt_t *
179
+ primitive_fixed(char dtype, uint32_t flags, ndt_context_t *ctx)
180
+ {
181
+ switch (dtype) {
182
+ case '?': return ndt_primitive(Bool, flags, ctx);
183
+
184
+ case 'c': return ndt_char(Ascii, ctx);
185
+ case 'b': return ndt_primitive(Int8, flags, ctx);
186
+ case 'B': return ndt_primitive(Uint8, flags, ctx);
187
+
188
+ case 'h': return ndt_primitive(Int16, flags, ctx);
189
+ case 'i': return ndt_primitive(Int32, flags, ctx);
190
+ case 'l': return ndt_primitive(Int32, flags, ctx);
191
+ case 'q': return ndt_primitive(Int64, flags, ctx);
192
+
193
+ case 'H': return ndt_primitive(Uint16, flags, ctx);
194
+ case 'I': return ndt_primitive(Uint32, flags, ctx);
195
+ case 'L': return ndt_primitive(Uint32, flags, ctx);
196
+ case 'Q': return ndt_primitive(Uint64, flags, ctx);
197
+
198
+ case 'e': return ndt_primitive(Float16, flags, ctx);
199
+ case 'f': return ndt_primitive(Float32, flags, ctx);
200
+ case 'd': return ndt_primitive(Float64, flags, ctx);
201
+
202
+ case 'E': return ndt_primitive(Complex32, flags, ctx);
203
+ case 'F': return ndt_primitive(Complex64, flags, ctx);
204
+ case 'D': return ndt_primitive(Complex128, flags, ctx);
205
+
206
+ default:
207
+ ndt_err_format(ctx, NDT_ValueError,
208
+ "invalid or unsupported dtype '%c'", dtype);
209
+ return NULL;
210
+ }
211
+ }
212
+
213
+ static ndt_t *
214
+ make_dtype(char modifier, char dtype, ndt_context_t *ctx)
215
+ {
216
+ switch (modifier) {
217
+ case '@':
218
+ return primitive_native(dtype, ctx);
219
+ case '=':
220
+ return primitive_fixed(dtype, 0, ctx);
221
+ case '<':
222
+ return primitive_fixed(dtype, NDT_LITTLE_ENDIAN, ctx);
223
+ case '>':
224
+ return primitive_fixed(dtype, NDT_BIG_ENDIAN, ctx);
225
+ case '!':
226
+ return primitive_fixed(dtype, NDT_BIG_ENDIAN, ctx);
227
+ default:
228
+ ndt_err_format(ctx, NDT_RuntimeError, "invalid modifier '%c'",
229
+ modifier);
230
+ return NULL;
231
+ }
232
+ }
233
+
234
+ static ndt_t *
235
+ make_fixed_bytes(char *v, ndt_context_t *ctx)
236
+ {
237
+ uint16_opt_t align = {None, 0};
238
+ int64_t datasize = 1;
239
+
240
+ if (v != NULL) {
241
+ datasize = ndt_strtoll(v, 0, INT64_MAX, ctx);
242
+ ndt_free(v);
243
+ if (ndt_err_occurred(ctx)) {
244
+ return NULL;
245
+ }
246
+ }
247
+
248
+ if (datasize < 1) {
249
+ ndt_err_format(ctx, NDT_ValueError,
250
+ "fixed bytes datasize must be greater than 0");
251
+ return NULL;
252
+ }
253
+
254
+ return ndt_fixed_bytes(datasize, align, ctx);
255
+ }
256
+
257
+ static ndt_t *
258
+ make_dimensions(ndt_string_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
259
+ {
260
+ ndt_t *t;
261
+ int64_t shape;
262
+ int64_t i;
263
+
264
+ if (seq->len < 1 || seq->len > NDT_MAX_DIM) {
265
+ ndt_err_format(ctx, NDT_ValueError,
266
+ "number of dimensions must be between 1 and %d", NDT_MAX_DIM);
267
+ ndt_string_seq_del(seq);
268
+ ndt_del(type);
269
+ return NULL;
270
+ }
271
+
272
+ for (i=seq->len-1, t=type; i>=0; i--, type=t) {
273
+ shape = ndt_strtoll(seq->ptr[i], 0, INT_MAX, ctx);
274
+ if (ndt_err_occurred(ctx)) {
275
+ ndt_string_seq_del(seq);
276
+ return NULL;
277
+ }
278
+
279
+ t = ndt_fixed_dim(type, shape, INT64_MAX, ctx);
280
+ if (t == NULL) {
281
+ ndt_string_seq_del(seq);
282
+ return NULL;
283
+ }
284
+ }
285
+
286
+ ndt_string_seq_del(seq);
287
+
288
+ return t;
289
+ }
290
+
291
+ static ndt_field_t *
292
+ make_field(char *name, ndt_t *type, uint16_t padding, ndt_context_t *ctx)
293
+ {
294
+ uint16_opt_t align = {None, 0};
295
+ uint16_opt_t pack = {None, 0};
296
+ uint16_opt_t pad = {Some, 0};
297
+
298
+ pad.Some = padding;
299
+ return ndt_field(name, type, align, pack, pad, ctx);
300
+ }
301
+
302
+ static ndt_t *
303
+ make_record(ndt_field_seq_t *fields, ndt_context_t *ctx)
304
+ {
305
+ uint16_opt_t align = {None, 0};
306
+ uint16_opt_t pack = {None, 0};
307
+ ndt_t *t;
308
+ int64_t i;
309
+
310
+ fields = ndt_field_seq_finalize(fields);
311
+ if (fields == NULL) {
312
+ return ndt_record(Nonvariadic, NULL, 0, align, pack, ctx);
313
+ }
314
+
315
+ assert(fields->len >= 1);
316
+
317
+ fields->ptr[0].Concrete.align = 1;
318
+ fields->ptr[0].Concrete.explicit_align = true;
319
+
320
+ for (i = 1; i < fields->len; i++) {
321
+ uint16_t a = 1;
322
+ if (fields->ptr[i-1].Concrete.pad != 0) {
323
+ a = fields->ptr[i-1].type->align + fields->ptr[i-1].Concrete.pad;
324
+ }
325
+ fields->ptr[i].Concrete.align = a;
326
+ fields->ptr[i].Concrete.explicit_align = true;
327
+ }
328
+
329
+ t = ndt_record(Nonvariadic, fields->ptr, fields->len, align, pack, ctx);
330
+ ndt_free(fields);
331
+
332
+ return t;
333
+ }
334
+
335
+ static ndt_type_seq_t *
336
+ broadcast_seq_new(ndt_t *type, ndt_context_t *ctx)
337
+ {
338
+ ndt_t *t;
339
+
340
+ t = ndt_ellipsis_dim(NULL, type, ctx);
341
+ if (t == NULL) {
342
+ return NULL;
343
+ }
344
+
345
+ return ndt_type_seq_new(t, ctx);
346
+ }
347
+
348
+ static ndt_type_seq_t *
349
+ broadcast_seq_append(ndt_type_seq_t *seq, ndt_t *type, ndt_context_t *ctx)
350
+ {
351
+ ndt_t *t;
352
+
353
+ t = ndt_ellipsis_dim(NULL, type, ctx);
354
+ if (t == NULL) {
355
+ ndt_type_seq_del(seq);
356
+ return NULL;
357
+ }
358
+
359
+ return ndt_type_seq_append(seq, t, ctx);
360
+ }
361
+
362
+ #line 363 "bpgrammar.c" /* yacc.c:339 */
363
+
364
+ # ifndef YY_NULLPTR
365
+ # if defined __cplusplus && 201103L <= __cplusplus
366
+ # define YY_NULLPTR nullptr
367
+ # else
368
+ # define YY_NULLPTR 0
369
+ # endif
370
+ # endif
371
+
372
+ /* Enabling verbose error messages. */
373
+ #ifdef YYERROR_VERBOSE
374
+ # undef YYERROR_VERBOSE
375
+ # define YYERROR_VERBOSE 1
376
+ #else
377
+ # define YYERROR_VERBOSE 1
378
+ #endif
379
+
380
+ /* In a future release of Bison, this section will be replaced
381
+ by #include "bpgrammar.h". */
382
+ #ifndef YY_NDT_BP_BPGRAMMAR_H_INCLUDED
383
+ # define YY_NDT_BP_BPGRAMMAR_H_INCLUDED
384
+ /* Debug traces. */
385
+ #ifndef YYDEBUG
386
+ # define YYDEBUG 0
387
+ #endif
388
+ #if YYDEBUG
389
+ extern int ndt_bpdebug;
390
+ #endif
391
+ /* "%code requires" blocks. */
392
+ #line 292 "bpgrammar.y" /* yacc.c:355 */
393
+
394
+ #include <ctype.h>
395
+ #include <assert.h>
396
+ #include "ndtypes.h"
397
+ #include "parsefuncs.h"
398
+ #include "seq.h"
399
+ #include "overflow.h"
400
+ #define YY_TYPEDEF_YY_SCANNER_T
401
+ typedef void * yyscan_t;
402
+
403
+ #line 404 "bpgrammar.c" /* yacc.c:355 */
404
+
405
+ /* Token type. */
406
+ #ifndef YYTOKENTYPE
407
+ # define YYTOKENTYPE
408
+ enum yytokentype
409
+ {
410
+ ENDMARKER = 0,
411
+ BYTES = 258,
412
+ RECORD = 259,
413
+ PAD = 260,
414
+ AT = 261,
415
+ EQUAL = 262,
416
+ LESS = 263,
417
+ GREATER = 264,
418
+ BANG = 265,
419
+ COMMA = 266,
420
+ COLON = 267,
421
+ LPAREN = 268,
422
+ RPAREN = 269,
423
+ LBRACE = 270,
424
+ RBRACE = 271,
425
+ RARROW = 272,
426
+ ERRTOKEN = 273,
427
+ DTYPE = 274,
428
+ INTEGER = 275,
429
+ NAME = 276
430
+ };
431
+ #endif
432
+
433
+ /* Value type. */
434
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
435
+
436
+ union YYSTYPE
437
+ {
438
+ #line 325 "bpgrammar.y" /* yacc.c:355 */
439
+
440
+ ndt_t *ndt;
441
+ ndt_field_t *field;
442
+ ndt_field_seq_t *field_seq;
443
+ ndt_string_seq_t *string_seq;
444
+ ndt_type_seq_t *type_seq;
445
+ char *string;
446
+ unsigned char uchar;
447
+ uint16_t uint16;
448
+
449
+ #line 450 "bpgrammar.c" /* yacc.c:355 */
450
+ };
451
+
452
+ typedef union YYSTYPE YYSTYPE;
453
+ # define YYSTYPE_IS_TRIVIAL 1
454
+ # define YYSTYPE_IS_DECLARED 1
455
+ #endif
456
+
457
+ /* Location type. */
458
+ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
459
+ typedef struct YYLTYPE YYLTYPE;
460
+ struct YYLTYPE
461
+ {
462
+ int first_line;
463
+ int first_column;
464
+ int last_line;
465
+ int last_column;
466
+ };
467
+ # define YYLTYPE_IS_DECLARED 1
468
+ # define YYLTYPE_IS_TRIVIAL 1
469
+ #endif
470
+
471
+
472
+
473
+ int ndt_bpparse (yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx);
474
+ /* "%code provides" blocks. */
475
+ #line 303 "bpgrammar.y" /* yacc.c:355 */
476
+
477
+ #define YY_DECL extern int ndt_bplexfunc(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, ndt_context_t *ctx)
478
+ extern int ndt_bplexfunc(YYSTYPE *, YYLTYPE *, yyscan_t, ndt_context_t *);
479
+ void yyerror(YYLTYPE *loc, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx, const char *msg);
480
+
481
+ #line 482 "bpgrammar.c" /* yacc.c:355 */
482
+
483
+ #endif /* !YY_NDT_BP_BPGRAMMAR_H_INCLUDED */
484
+
485
+ /* Copy the second part of user declarations. */
486
+
487
+ #line 488 "bpgrammar.c" /* yacc.c:358 */
488
+
489
+ #ifdef short
490
+ # undef short
491
+ #endif
492
+
493
+ #ifdef YYTYPE_UINT8
494
+ typedef YYTYPE_UINT8 yytype_uint8;
495
+ #else
496
+ typedef unsigned char yytype_uint8;
497
+ #endif
498
+
499
+ #ifdef YYTYPE_INT8
500
+ typedef YYTYPE_INT8 yytype_int8;
501
+ #else
502
+ typedef signed char yytype_int8;
503
+ #endif
504
+
505
+ #ifdef YYTYPE_UINT16
506
+ typedef YYTYPE_UINT16 yytype_uint16;
507
+ #else
508
+ typedef unsigned short int yytype_uint16;
509
+ #endif
510
+
511
+ #ifdef YYTYPE_INT16
512
+ typedef YYTYPE_INT16 yytype_int16;
513
+ #else
514
+ typedef short int yytype_int16;
515
+ #endif
516
+
517
+ #ifndef YYSIZE_T
518
+ # ifdef __SIZE_TYPE__
519
+ # define YYSIZE_T __SIZE_TYPE__
520
+ # elif defined size_t
521
+ # define YYSIZE_T size_t
522
+ # elif ! defined YYSIZE_T
523
+ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
524
+ # define YYSIZE_T size_t
525
+ # else
526
+ # define YYSIZE_T unsigned int
527
+ # endif
528
+ #endif
529
+
530
+ #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
531
+
532
+ #ifndef YY_
533
+ # if defined YYENABLE_NLS && YYENABLE_NLS
534
+ # if ENABLE_NLS
535
+ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
536
+ # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
537
+ # endif
538
+ # endif
539
+ # ifndef YY_
540
+ # define YY_(Msgid) Msgid
541
+ # endif
542
+ #endif
543
+
544
+ #ifndef YY_ATTRIBUTE
545
+ # if (defined __GNUC__ \
546
+ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
547
+ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
548
+ # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
549
+ # else
550
+ # define YY_ATTRIBUTE(Spec) /* empty */
551
+ # endif
552
+ #endif
553
+
554
+ #ifndef YY_ATTRIBUTE_PURE
555
+ # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
556
+ #endif
557
+
558
+ #ifndef YY_ATTRIBUTE_UNUSED
559
+ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
560
+ #endif
561
+
562
+ #if !defined _Noreturn \
563
+ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
564
+ # if defined _MSC_VER && 1200 <= _MSC_VER
565
+ # define _Noreturn __declspec (noreturn)
566
+ # else
567
+ # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
568
+ # endif
569
+ #endif
570
+
571
+ /* Suppress unused-variable warnings by "using" E. */
572
+ #if ! defined lint || defined __GNUC__
573
+ # define YYUSE(E) ((void) (E))
574
+ #else
575
+ # define YYUSE(E) /* empty */
576
+ #endif
577
+
578
+ #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
579
+ /* Suppress an incorrect diagnostic about yylval being uninitialized. */
580
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
581
+ _Pragma ("GCC diagnostic push") \
582
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
583
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
584
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
585
+ _Pragma ("GCC diagnostic pop")
586
+ #else
587
+ # define YY_INITIAL_VALUE(Value) Value
588
+ #endif
589
+ #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
590
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
591
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_END
592
+ #endif
593
+ #ifndef YY_INITIAL_VALUE
594
+ # define YY_INITIAL_VALUE(Value) /* Nothing. */
595
+ #endif
596
+
597
+
598
+ #if ! defined yyoverflow || YYERROR_VERBOSE
599
+
600
+ /* The parser invokes alloca or malloc; define the necessary symbols. */
601
+
602
+ # ifdef YYSTACK_USE_ALLOCA
603
+ # if YYSTACK_USE_ALLOCA
604
+ # ifdef __GNUC__
605
+ # define YYSTACK_ALLOC __builtin_alloca
606
+ # elif defined __BUILTIN_VA_ARG_INCR
607
+ # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
608
+ # elif defined _AIX
609
+ # define YYSTACK_ALLOC __alloca
610
+ # elif defined _MSC_VER
611
+ # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
612
+ # define alloca _alloca
613
+ # else
614
+ # define YYSTACK_ALLOC alloca
615
+ # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
616
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
617
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
618
+ # ifndef EXIT_SUCCESS
619
+ # define EXIT_SUCCESS 0
620
+ # endif
621
+ # endif
622
+ # endif
623
+ # endif
624
+ # endif
625
+
626
+ # ifdef YYSTACK_ALLOC
627
+ /* Pacify GCC's 'empty if-body' warning. */
628
+ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
629
+ # ifndef YYSTACK_ALLOC_MAXIMUM
630
+ /* The OS might guarantee only one guard page at the bottom of the stack,
631
+ and a page size can be as small as 4096 bytes. So we cannot safely
632
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
633
+ to allow for a few compiler-allocated temporary stack slots. */
634
+ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
635
+ # endif
636
+ # else
637
+ # define YYSTACK_ALLOC YYMALLOC
638
+ # define YYSTACK_FREE YYFREE
639
+ # ifndef YYSTACK_ALLOC_MAXIMUM
640
+ # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
641
+ # endif
642
+ # if (defined __cplusplus && ! defined EXIT_SUCCESS \
643
+ && ! ((defined YYMALLOC || defined malloc) \
644
+ && (defined YYFREE || defined free)))
645
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
646
+ # ifndef EXIT_SUCCESS
647
+ # define EXIT_SUCCESS 0
648
+ # endif
649
+ # endif
650
+ # ifndef YYMALLOC
651
+ # define YYMALLOC malloc
652
+ # if ! defined malloc && ! defined EXIT_SUCCESS
653
+ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
654
+ # endif
655
+ # endif
656
+ # ifndef YYFREE
657
+ # define YYFREE free
658
+ # if ! defined free && ! defined EXIT_SUCCESS
659
+ void free (void *); /* INFRINGES ON USER NAME SPACE */
660
+ # endif
661
+ # endif
662
+ # endif
663
+ #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
664
+
665
+
666
+ #if (! defined yyoverflow \
667
+ && (! defined __cplusplus \
668
+ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
669
+ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
670
+
671
+ /* A type that is properly aligned for any stack member. */
672
+ union yyalloc
673
+ {
674
+ yytype_int16 yyss_alloc;
675
+ YYSTYPE yyvs_alloc;
676
+ YYLTYPE yyls_alloc;
677
+ };
678
+
679
+ /* The size of the maximum gap between one aligned stack and the next. */
680
+ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
681
+
682
+ /* The size of an array large to enough to hold all stacks, each with
683
+ N elements. */
684
+ # define YYSTACK_BYTES(N) \
685
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
686
+ + 2 * YYSTACK_GAP_MAXIMUM)
687
+
688
+ # define YYCOPY_NEEDED 1
689
+
690
+ /* Relocate STACK from its old location to the new one. The
691
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
692
+ elements in the stack, and YYPTR gives the new location of the
693
+ stack. Advance YYPTR to a properly aligned location for the next
694
+ stack. */
695
+ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
696
+ do \
697
+ { \
698
+ YYSIZE_T yynewbytes; \
699
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
700
+ Stack = &yyptr->Stack_alloc; \
701
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
702
+ yyptr += yynewbytes / sizeof (*yyptr); \
703
+ } \
704
+ while (0)
705
+
706
+ #endif
707
+
708
+ #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
709
+ /* Copy COUNT objects from SRC to DST. The source and destination do
710
+ not overlap. */
711
+ # ifndef YYCOPY
712
+ # if defined __GNUC__ && 1 < __GNUC__
713
+ # define YYCOPY(Dst, Src, Count) \
714
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
715
+ # else
716
+ # define YYCOPY(Dst, Src, Count) \
717
+ do \
718
+ { \
719
+ YYSIZE_T yyi; \
720
+ for (yyi = 0; yyi < (Count); yyi++) \
721
+ (Dst)[yyi] = (Src)[yyi]; \
722
+ } \
723
+ while (0)
724
+ # endif
725
+ # endif
726
+ #endif /* !YYCOPY_NEEDED */
727
+
728
+ /* YYFINAL -- State number of the termination state. */
729
+ #define YYFINAL 20
730
+ /* YYLAST -- Last index in YYTABLE. */
731
+ #define YYLAST 82
732
+
733
+ /* YYNTOKENS -- Number of terminals. */
734
+ #define YYNTOKENS 22
735
+ /* YYNNTS -- Number of nonterminals. */
736
+ #define YYNNTS 13
737
+ /* YYNRULES -- Number of rules. */
738
+ #define YYNRULES 27
739
+ /* YYNSTATES -- Number of states. */
740
+ #define YYNSTATES 42
741
+
742
+ /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
743
+ by yylex, with out-of-bounds checking. */
744
+ #define YYUNDEFTOK 2
745
+ #define YYMAXUTOK 276
746
+
747
+ #define YYTRANSLATE(YYX) \
748
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
749
+
750
+ /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
751
+ as returned by yylex, without out-of-bounds checking. */
752
+ static const yytype_uint8 yytranslate[] =
753
+ {
754
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
755
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
756
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
757
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
758
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
759
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
760
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
761
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
762
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
763
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
764
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
765
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
766
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
767
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
768
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
769
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
770
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
771
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
772
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
773
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
774
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
775
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
776
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
777
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
778
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
779
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
780
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
781
+ 15, 16, 17, 18, 19, 20, 21
782
+ };
783
+
784
+ #if YYDEBUG
785
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
786
+ static const yytype_uint16 yyrline[] =
787
+ {
788
+ 0, 379, 379, 382, 383, 384, 387, 388, 391, 392,
789
+ 393, 396, 399, 400, 403, 406, 409, 410, 413, 414,
790
+ 415, 416, 417, 418, 421, 422, 425, 426
791
+ };
792
+ #endif
793
+
794
+ #if YYDEBUG || YYERROR_VERBOSE || 1
795
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
796
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
797
+ static const char *const yytname[] =
798
+ {
799
+ "\"end of file\"", "error", "$undefined", "BYTES", "RECORD", "PAD",
800
+ "AT", "EQUAL", "LESS", "GREATER", "BANG", "COMMA", "COLON", "LPAREN",
801
+ "RPAREN", "LBRACE", "RBRACE", "RARROW", "ERRTOKEN", "DTYPE", "INTEGER",
802
+ "NAME", "$accept", "input", "datatype", "dimensions", "dtype", "record",
803
+ "field_seq", "field", "function", "dtype_seq", "modifier", "repeat",
804
+ "padding", YY_NULLPTR
805
+ };
806
+ #endif
807
+
808
+ # ifdef YYPRINT
809
+ /* YYTOKNUM[NUM] -- (External) token number corresponding to the
810
+ (internal) symbol number NUM (which must be that of a token). */
811
+ static const yytype_uint16 yytoknum[] =
812
+ {
813
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
814
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
815
+ 275, 276
816
+ };
817
+ # endif
818
+
819
+ #define YYPACT_NINF -17
820
+
821
+ #define yypact_value_is_default(Yystate) \
822
+ (!!((Yystate) == (-17)))
823
+
824
+ #define YYTABLE_NINF -25
825
+
826
+ #define yytable_value_is_error(Yytable_value) \
827
+ 0
828
+
829
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
830
+ STATE-NUM. */
831
+ static const yytype_int8 yypact[] =
832
+ {
833
+ 31, -12, -17, -17, -17, -17, -17, -16, -17, 6,
834
+ 7, 1, -17, -17, 39, -10, 8, 31, -17, -9,
835
+ -17, -17, 62, -17, -17, -17, -2, 16, -17, -8,
836
+ 62, -17, 54, -7, -17, -17, -17, -17, 3, -17,
837
+ 12, -17
838
+ };
839
+
840
+ /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
841
+ Performed when YYTABLE does not specify something else to do. Zero
842
+ means the default is an error. */
843
+ static const yytype_uint8 yydefact[] =
844
+ {
845
+ 18, 0, 19, 20, 21, 22, 23, 0, 25, 0,
846
+ 0, 16, 10, 5, 18, 0, 0, 18, 6, 0,
847
+ 1, 2, 18, 17, 8, 9, 0, 18, 12, 0,
848
+ 18, 16, 15, 0, 11, 13, 7, 3, 0, 26,
849
+ 14, 27
850
+ };
851
+
852
+ /* YYPGOTO[NTERM-NUM]. */
853
+ static const yytype_int8 yypgoto[] =
854
+ {
855
+ -17, -17, 21, -17, -14, -17, -17, 0, -17, 9,
856
+ -17, -17, -17
857
+ };
858
+
859
+ /* YYDEFGOTO[NTERM-NUM]. */
860
+ static const yytype_int8 yydefgoto[] =
861
+ {
862
+ -1, 9, 26, 19, 11, 12, 27, 28, 13, 14,
863
+ 15, 16, 40
864
+ };
865
+
866
+ /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
867
+ positive, shift that token. If negative, reduce the rule whose
868
+ number is the opposite. If YYTABLE_NINF, syntax error. */
869
+ static const yytype_int8 yytable[] =
870
+ {
871
+ 23, -4, 29, 17, 18, 30, 20, 21, 31, 24,
872
+ 33, 25, 36, -4, 38, 39, 37, 41, 23, -24,
873
+ 1, 10, 2, 3, 4, 5, 6, 35, 0, 7,
874
+ 0, 32, 34, 0, -24, 1, 8, 2, 3, 4,
875
+ 5, 6, -24, 1, 7, 2, 3, 4, 5, 6,
876
+ 0, 8, 0, 0, 0, 0, 22, -24, 1, 8,
877
+ 2, 3, 4, 5, 6, -24, 1, 0, 2, 3,
878
+ 4, 5, 6, -18, 8, 0, 0, 0, 0, 0,
879
+ 0, 0, 8
880
+ };
881
+
882
+ static const yytype_int8 yycheck[] =
883
+ {
884
+ 14, 0, 11, 15, 20, 14, 0, 0, 22, 19,
885
+ 12, 3, 20, 12, 21, 12, 30, 5, 32, 3,
886
+ 4, 0, 6, 7, 8, 9, 10, 27, -1, 13,
887
+ -1, 22, 16, -1, 3, 4, 20, 6, 7, 8,
888
+ 9, 10, 3, 4, 13, 6, 7, 8, 9, 10,
889
+ -1, 20, -1, -1, -1, -1, 17, 3, 4, 20,
890
+ 6, 7, 8, 9, 10, 3, 4, -1, 6, 7,
891
+ 8, 9, 10, 19, 20, -1, -1, -1, -1, -1,
892
+ -1, -1, 20
893
+ };
894
+
895
+ /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
896
+ symbol of state STATE-NUM. */
897
+ static const yytype_uint8 yystos[] =
898
+ {
899
+ 0, 4, 6, 7, 8, 9, 10, 13, 20, 23,
900
+ 24, 26, 27, 30, 31, 32, 33, 15, 20, 25,
901
+ 0, 0, 17, 26, 19, 3, 24, 28, 29, 11,
902
+ 14, 26, 31, 12, 16, 29, 20, 26, 21, 12,
903
+ 34, 5
904
+ };
905
+
906
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
907
+ static const yytype_uint8 yyr1[] =
908
+ {
909
+ 0, 22, 23, 24, 24, 24, 25, 25, 26, 26,
910
+ 26, 27, 28, 28, 29, 30, 31, 31, 32, 32,
911
+ 32, 32, 32, 32, 33, 33, 34, 34
912
+ };
913
+
914
+ /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
915
+ static const yytype_uint8 yyr2[] =
916
+ {
917
+ 0, 2, 2, 4, 1, 1, 1, 3, 2, 2,
918
+ 1, 4, 1, 2, 5, 3, 1, 2, 0, 1,
919
+ 1, 1, 1, 1, 0, 1, 0, 2
920
+ };
921
+
922
+
923
+ #define yyerrok (yyerrstatus = 0)
924
+ #define yyclearin (yychar = YYEMPTY)
925
+ #define YYEMPTY (-2)
926
+ #define YYEOF 0
927
+
928
+ #define YYACCEPT goto yyacceptlab
929
+ #define YYABORT goto yyabortlab
930
+ #define YYERROR goto yyerrorlab
931
+
932
+
933
+ #define YYRECOVERING() (!!yyerrstatus)
934
+
935
+ #define YYBACKUP(Token, Value) \
936
+ do \
937
+ if (yychar == YYEMPTY) \
938
+ { \
939
+ yychar = (Token); \
940
+ yylval = (Value); \
941
+ YYPOPSTACK (yylen); \
942
+ yystate = *yyssp; \
943
+ goto yybackup; \
944
+ } \
945
+ else \
946
+ { \
947
+ yyerror (&yylloc, scanner, ast, ctx, YY_("syntax error: cannot back up")); \
948
+ YYERROR; \
949
+ } \
950
+ while (0)
951
+
952
+ /* Error token number */
953
+ #define YYTERROR 1
954
+ #define YYERRCODE 256
955
+
956
+
957
+ /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
958
+ If N is 0, then set CURRENT to the empty location which ends
959
+ the previous symbol: RHS[0] (always defined). */
960
+
961
+ #ifndef YYLLOC_DEFAULT
962
+ # define YYLLOC_DEFAULT(Current, Rhs, N) \
963
+ do \
964
+ if (N) \
965
+ { \
966
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
967
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
968
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
969
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
970
+ } \
971
+ else \
972
+ { \
973
+ (Current).first_line = (Current).last_line = \
974
+ YYRHSLOC (Rhs, 0).last_line; \
975
+ (Current).first_column = (Current).last_column = \
976
+ YYRHSLOC (Rhs, 0).last_column; \
977
+ } \
978
+ while (0)
979
+ #endif
980
+
981
+ #define YYRHSLOC(Rhs, K) ((Rhs)[K])
982
+
983
+
984
+ /* Enable debugging if requested. */
985
+ #if YYDEBUG
986
+
987
+ # ifndef YYFPRINTF
988
+ # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
989
+ # define YYFPRINTF fprintf
990
+ # endif
991
+
992
+ # define YYDPRINTF(Args) \
993
+ do { \
994
+ if (yydebug) \
995
+ YYFPRINTF Args; \
996
+ } while (0)
997
+
998
+
999
+ /* YY_LOCATION_PRINT -- Print the location on the stream.
1000
+ This macro was not mandated originally: define only if we know
1001
+ we won't break user code: when these are the locations we know. */
1002
+
1003
+ #ifndef YY_LOCATION_PRINT
1004
+ # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1005
+
1006
+ /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
1007
+
1008
+ YY_ATTRIBUTE_UNUSED
1009
+ static unsigned
1010
+ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
1011
+ {
1012
+ unsigned res = 0;
1013
+ int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
1014
+ if (0 <= yylocp->first_line)
1015
+ {
1016
+ res += YYFPRINTF (yyo, "%d", yylocp->first_line);
1017
+ if (0 <= yylocp->first_column)
1018
+ res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
1019
+ }
1020
+ if (0 <= yylocp->last_line)
1021
+ {
1022
+ if (yylocp->first_line < yylocp->last_line)
1023
+ {
1024
+ res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
1025
+ if (0 <= end_col)
1026
+ res += YYFPRINTF (yyo, ".%d", end_col);
1027
+ }
1028
+ else if (0 <= end_col && yylocp->first_column < end_col)
1029
+ res += YYFPRINTF (yyo, "-%d", end_col);
1030
+ }
1031
+ return res;
1032
+ }
1033
+
1034
+ # define YY_LOCATION_PRINT(File, Loc) \
1035
+ yy_location_print_ (File, &(Loc))
1036
+
1037
+ # else
1038
+ # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1039
+ # endif
1040
+ #endif
1041
+
1042
+
1043
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1044
+ do { \
1045
+ if (yydebug) \
1046
+ { \
1047
+ YYFPRINTF (stderr, "%s ", Title); \
1048
+ yy_symbol_print (stderr, \
1049
+ Type, Value, Location, scanner, ast, ctx); \
1050
+ YYFPRINTF (stderr, "\n"); \
1051
+ } \
1052
+ } while (0)
1053
+
1054
+
1055
+ /*----------------------------------------.
1056
+ | Print this symbol's value on YYOUTPUT. |
1057
+ `----------------------------------------*/
1058
+
1059
+ static void
1060
+ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx)
1061
+ {
1062
+ FILE *yyo = yyoutput;
1063
+ YYUSE (yyo);
1064
+ YYUSE (yylocationp);
1065
+ YYUSE (scanner);
1066
+ YYUSE (ast);
1067
+ YYUSE (ctx);
1068
+ if (!yyvaluep)
1069
+ return;
1070
+ # ifdef YYPRINT
1071
+ if (yytype < YYNTOKENS)
1072
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1073
+ # endif
1074
+ YYUSE (yytype);
1075
+ }
1076
+
1077
+
1078
+ /*--------------------------------.
1079
+ | Print this symbol on YYOUTPUT. |
1080
+ `--------------------------------*/
1081
+
1082
+ static void
1083
+ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx)
1084
+ {
1085
+ YYFPRINTF (yyoutput, "%s %s (",
1086
+ yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1087
+
1088
+ YY_LOCATION_PRINT (yyoutput, *yylocationp);
1089
+ YYFPRINTF (yyoutput, ": ");
1090
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, scanner, ast, ctx);
1091
+ YYFPRINTF (yyoutput, ")");
1092
+ }
1093
+
1094
+ /*------------------------------------------------------------------.
1095
+ | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1096
+ | TOP (included). |
1097
+ `------------------------------------------------------------------*/
1098
+
1099
+ static void
1100
+ yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1101
+ {
1102
+ YYFPRINTF (stderr, "Stack now");
1103
+ for (; yybottom <= yytop; yybottom++)
1104
+ {
1105
+ int yybot = *yybottom;
1106
+ YYFPRINTF (stderr, " %d", yybot);
1107
+ }
1108
+ YYFPRINTF (stderr, "\n");
1109
+ }
1110
+
1111
+ # define YY_STACK_PRINT(Bottom, Top) \
1112
+ do { \
1113
+ if (yydebug) \
1114
+ yy_stack_print ((Bottom), (Top)); \
1115
+ } while (0)
1116
+
1117
+
1118
+ /*------------------------------------------------.
1119
+ | Report that the YYRULE is going to be reduced. |
1120
+ `------------------------------------------------*/
1121
+
1122
+ static void
1123
+ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx)
1124
+ {
1125
+ unsigned long int yylno = yyrline[yyrule];
1126
+ int yynrhs = yyr2[yyrule];
1127
+ int yyi;
1128
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1129
+ yyrule - 1, yylno);
1130
+ /* The symbols being reduced. */
1131
+ for (yyi = 0; yyi < yynrhs; yyi++)
1132
+ {
1133
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
1134
+ yy_symbol_print (stderr,
1135
+ yystos[yyssp[yyi + 1 - yynrhs]],
1136
+ &(yyvsp[(yyi + 1) - (yynrhs)])
1137
+ , &(yylsp[(yyi + 1) - (yynrhs)]) , scanner, ast, ctx);
1138
+ YYFPRINTF (stderr, "\n");
1139
+ }
1140
+ }
1141
+
1142
+ # define YY_REDUCE_PRINT(Rule) \
1143
+ do { \
1144
+ if (yydebug) \
1145
+ yy_reduce_print (yyssp, yyvsp, yylsp, Rule, scanner, ast, ctx); \
1146
+ } while (0)
1147
+
1148
+ /* Nonzero means print parse trace. It is left uninitialized so that
1149
+ multiple parsers can coexist. */
1150
+ int yydebug;
1151
+ #else /* !YYDEBUG */
1152
+ # define YYDPRINTF(Args)
1153
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1154
+ # define YY_STACK_PRINT(Bottom, Top)
1155
+ # define YY_REDUCE_PRINT(Rule)
1156
+ #endif /* !YYDEBUG */
1157
+
1158
+
1159
+ /* YYINITDEPTH -- initial size of the parser's stacks. */
1160
+ #ifndef YYINITDEPTH
1161
+ # define YYINITDEPTH 200
1162
+ #endif
1163
+
1164
+ /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1165
+ if the built-in stack extension method is used).
1166
+
1167
+ Do not make this value too large; the results are undefined if
1168
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1169
+ evaluated with infinite-precision integer arithmetic. */
1170
+
1171
+ #ifndef YYMAXDEPTH
1172
+ # define YYMAXDEPTH 10000
1173
+ #endif
1174
+
1175
+
1176
+ #if YYERROR_VERBOSE
1177
+
1178
+ # ifndef yystrlen
1179
+ # if defined __GLIBC__ && defined _STRING_H
1180
+ # define yystrlen strlen
1181
+ # else
1182
+ /* Return the length of YYSTR. */
1183
+ static YYSIZE_T
1184
+ yystrlen (const char *yystr)
1185
+ {
1186
+ YYSIZE_T yylen;
1187
+ for (yylen = 0; yystr[yylen]; yylen++)
1188
+ continue;
1189
+ return yylen;
1190
+ }
1191
+ # endif
1192
+ # endif
1193
+
1194
+ # ifndef yystpcpy
1195
+ # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1196
+ # define yystpcpy stpcpy
1197
+ # else
1198
+ /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1199
+ YYDEST. */
1200
+ static char *
1201
+ yystpcpy (char *yydest, const char *yysrc)
1202
+ {
1203
+ char *yyd = yydest;
1204
+ const char *yys = yysrc;
1205
+
1206
+ while ((*yyd++ = *yys++) != '\0')
1207
+ continue;
1208
+
1209
+ return yyd - 1;
1210
+ }
1211
+ # endif
1212
+ # endif
1213
+
1214
+ # ifndef yytnamerr
1215
+ /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1216
+ quotes and backslashes, so that it's suitable for yyerror. The
1217
+ heuristic is that double-quoting is unnecessary unless the string
1218
+ contains an apostrophe, a comma, or backslash (other than
1219
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
1220
+ null, do not copy; instead, return the length of what the result
1221
+ would have been. */
1222
+ static YYSIZE_T
1223
+ yytnamerr (char *yyres, const char *yystr)
1224
+ {
1225
+ if (*yystr == '"')
1226
+ {
1227
+ YYSIZE_T yyn = 0;
1228
+ char const *yyp = yystr;
1229
+
1230
+ for (;;)
1231
+ switch (*++yyp)
1232
+ {
1233
+ case '\'':
1234
+ case ',':
1235
+ goto do_not_strip_quotes;
1236
+
1237
+ case '\\':
1238
+ if (*++yyp != '\\')
1239
+ goto do_not_strip_quotes;
1240
+ /* Fall through. */
1241
+ default:
1242
+ if (yyres)
1243
+ yyres[yyn] = *yyp;
1244
+ yyn++;
1245
+ break;
1246
+
1247
+ case '"':
1248
+ if (yyres)
1249
+ yyres[yyn] = '\0';
1250
+ return yyn;
1251
+ }
1252
+ do_not_strip_quotes: ;
1253
+ }
1254
+
1255
+ if (! yyres)
1256
+ return yystrlen (yystr);
1257
+
1258
+ return yystpcpy (yyres, yystr) - yyres;
1259
+ }
1260
+ # endif
1261
+
1262
+ /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1263
+ about the unexpected token YYTOKEN for the state stack whose top is
1264
+ YYSSP.
1265
+
1266
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1267
+ not large enough to hold the message. In that case, also set
1268
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1269
+ required number of bytes is too large to store. */
1270
+ static int
1271
+ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1272
+ yytype_int16 *yyssp, int yytoken)
1273
+ {
1274
+ YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1275
+ YYSIZE_T yysize = yysize0;
1276
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1277
+ /* Internationalized format string. */
1278
+ const char *yyformat = YY_NULLPTR;
1279
+ /* Arguments of yyformat. */
1280
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1281
+ /* Number of reported tokens (one for the "unexpected", one per
1282
+ "expected"). */
1283
+ int yycount = 0;
1284
+
1285
+ /* There are many possibilities here to consider:
1286
+ - If this state is a consistent state with a default action, then
1287
+ the only way this function was invoked is if the default action
1288
+ is an error action. In that case, don't check for expected
1289
+ tokens because there are none.
1290
+ - The only way there can be no lookahead present (in yychar) is if
1291
+ this state is a consistent state with a default action. Thus,
1292
+ detecting the absence of a lookahead is sufficient to determine
1293
+ that there is no unexpected or expected token to report. In that
1294
+ case, just report a simple "syntax error".
1295
+ - Don't assume there isn't a lookahead just because this state is a
1296
+ consistent state with a default action. There might have been a
1297
+ previous inconsistent state, consistent state with a non-default
1298
+ action, or user semantic action that manipulated yychar.
1299
+ - Of course, the expected token list depends on states to have
1300
+ correct lookahead information, and it depends on the parser not
1301
+ to perform extra reductions after fetching a lookahead from the
1302
+ scanner and before detecting a syntax error. Thus, state merging
1303
+ (from LALR or IELR) and default reductions corrupt the expected
1304
+ token list. However, the list is correct for canonical LR with
1305
+ one exception: it will still contain any token that will not be
1306
+ accepted due to an error action in a later state.
1307
+ */
1308
+ if (yytoken != YYEMPTY)
1309
+ {
1310
+ int yyn = yypact[*yyssp];
1311
+ yyarg[yycount++] = yytname[yytoken];
1312
+ if (!yypact_value_is_default (yyn))
1313
+ {
1314
+ /* Start YYX at -YYN if negative to avoid negative indexes in
1315
+ YYCHECK. In other words, skip the first -YYN actions for
1316
+ this state because they are default actions. */
1317
+ int yyxbegin = yyn < 0 ? -yyn : 0;
1318
+ /* Stay within bounds of both yycheck and yytname. */
1319
+ int yychecklim = YYLAST - yyn + 1;
1320
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1321
+ int yyx;
1322
+
1323
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1324
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1325
+ && !yytable_value_is_error (yytable[yyx + yyn]))
1326
+ {
1327
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1328
+ {
1329
+ yycount = 1;
1330
+ yysize = yysize0;
1331
+ break;
1332
+ }
1333
+ yyarg[yycount++] = yytname[yyx];
1334
+ {
1335
+ YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1336
+ if (! (yysize <= yysize1
1337
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1338
+ return 2;
1339
+ yysize = yysize1;
1340
+ }
1341
+ }
1342
+ }
1343
+ }
1344
+
1345
+ switch (yycount)
1346
+ {
1347
+ # define YYCASE_(N, S) \
1348
+ case N: \
1349
+ yyformat = S; \
1350
+ break
1351
+ YYCASE_(0, YY_("syntax error"));
1352
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
1353
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1354
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1355
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1356
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1357
+ # undef YYCASE_
1358
+ }
1359
+
1360
+ {
1361
+ YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1362
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1363
+ return 2;
1364
+ yysize = yysize1;
1365
+ }
1366
+
1367
+ if (*yymsg_alloc < yysize)
1368
+ {
1369
+ *yymsg_alloc = 2 * yysize;
1370
+ if (! (yysize <= *yymsg_alloc
1371
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1372
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1373
+ return 1;
1374
+ }
1375
+
1376
+ /* Avoid sprintf, as that infringes on the user's name space.
1377
+ Don't have undefined behavior even if the translation
1378
+ produced a string with the wrong number of "%s"s. */
1379
+ {
1380
+ char *yyp = *yymsg;
1381
+ int yyi = 0;
1382
+ while ((*yyp = *yyformat) != '\0')
1383
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1384
+ {
1385
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
1386
+ yyformat += 2;
1387
+ }
1388
+ else
1389
+ {
1390
+ yyp++;
1391
+ yyformat++;
1392
+ }
1393
+ }
1394
+ return 0;
1395
+ }
1396
+ #endif /* YYERROR_VERBOSE */
1397
+
1398
+ /*-----------------------------------------------.
1399
+ | Release the memory associated to this symbol. |
1400
+ `-----------------------------------------------*/
1401
+
1402
+ static void
1403
+ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx)
1404
+ {
1405
+ YYUSE (yyvaluep);
1406
+ YYUSE (yylocationp);
1407
+ YYUSE (scanner);
1408
+ YYUSE (ast);
1409
+ YYUSE (ctx);
1410
+ if (!yymsg)
1411
+ yymsg = "Deleting";
1412
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1413
+
1414
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1415
+ switch (yytype)
1416
+ {
1417
+ case 20: /* INTEGER */
1418
+ #line 374 "bpgrammar.y" /* yacc.c:1257 */
1419
+ { ndt_free(((*yyvaluep).string)); }
1420
+ #line 1421 "bpgrammar.c" /* yacc.c:1257 */
1421
+ break;
1422
+
1423
+ case 21: /* NAME */
1424
+ #line 374 "bpgrammar.y" /* yacc.c:1257 */
1425
+ { ndt_free(((*yyvaluep).string)); }
1426
+ #line 1427 "bpgrammar.c" /* yacc.c:1257 */
1427
+ break;
1428
+
1429
+ case 23: /* input */
1430
+ #line 369 "bpgrammar.y" /* yacc.c:1257 */
1431
+ { ndt_del(((*yyvaluep).ndt)); }
1432
+ #line 1433 "bpgrammar.c" /* yacc.c:1257 */
1433
+ break;
1434
+
1435
+ case 24: /* datatype */
1436
+ #line 369 "bpgrammar.y" /* yacc.c:1257 */
1437
+ { ndt_del(((*yyvaluep).ndt)); }
1438
+ #line 1439 "bpgrammar.c" /* yacc.c:1257 */
1439
+ break;
1440
+
1441
+ case 25: /* dimensions */
1442
+ #line 372 "bpgrammar.y" /* yacc.c:1257 */
1443
+ { ndt_string_seq_del(((*yyvaluep).string_seq)); }
1444
+ #line 1445 "bpgrammar.c" /* yacc.c:1257 */
1445
+ break;
1446
+
1447
+ case 26: /* dtype */
1448
+ #line 369 "bpgrammar.y" /* yacc.c:1257 */
1449
+ { ndt_del(((*yyvaluep).ndt)); }
1450
+ #line 1451 "bpgrammar.c" /* yacc.c:1257 */
1451
+ break;
1452
+
1453
+ case 27: /* record */
1454
+ #line 369 "bpgrammar.y" /* yacc.c:1257 */
1455
+ { ndt_del(((*yyvaluep).ndt)); }
1456
+ #line 1457 "bpgrammar.c" /* yacc.c:1257 */
1457
+ break;
1458
+
1459
+ case 28: /* field_seq */
1460
+ #line 371 "bpgrammar.y" /* yacc.c:1257 */
1461
+ { ndt_field_seq_del(((*yyvaluep).field_seq)); }
1462
+ #line 1463 "bpgrammar.c" /* yacc.c:1257 */
1463
+ break;
1464
+
1465
+ case 29: /* field */
1466
+ #line 370 "bpgrammar.y" /* yacc.c:1257 */
1467
+ { ndt_field_del(((*yyvaluep).field)); }
1468
+ #line 1469 "bpgrammar.c" /* yacc.c:1257 */
1469
+ break;
1470
+
1471
+ case 30: /* function */
1472
+ #line 369 "bpgrammar.y" /* yacc.c:1257 */
1473
+ { ndt_del(((*yyvaluep).ndt)); }
1474
+ #line 1475 "bpgrammar.c" /* yacc.c:1257 */
1475
+ break;
1476
+
1477
+ case 31: /* dtype_seq */
1478
+ #line 373 "bpgrammar.y" /* yacc.c:1257 */
1479
+ { ndt_type_seq_del(((*yyvaluep).type_seq)); }
1480
+ #line 1481 "bpgrammar.c" /* yacc.c:1257 */
1481
+ break;
1482
+
1483
+ case 33: /* repeat */
1484
+ #line 374 "bpgrammar.y" /* yacc.c:1257 */
1485
+ { ndt_free(((*yyvaluep).string)); }
1486
+ #line 1487 "bpgrammar.c" /* yacc.c:1257 */
1487
+ break;
1488
+
1489
+
1490
+ default:
1491
+ break;
1492
+ }
1493
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
1494
+ }
1495
+
1496
+
1497
+
1498
+
1499
+ /*----------.
1500
+ | yyparse. |
1501
+ `----------*/
1502
+
1503
+ int
1504
+ yyparse (yyscan_t scanner, ndt_t **ast, ndt_context_t *ctx)
1505
+ {
1506
+ /* The lookahead symbol. */
1507
+ int yychar;
1508
+
1509
+
1510
+ /* The semantic value of the lookahead symbol. */
1511
+ /* Default value used for initialization, for pacifying older GCCs
1512
+ or non-GCC compilers. */
1513
+ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1514
+ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1515
+
1516
+ /* Location data for the lookahead symbol. */
1517
+ static YYLTYPE yyloc_default
1518
+ # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1519
+ = { 1, 1, 1, 1 }
1520
+ # endif
1521
+ ;
1522
+ YYLTYPE yylloc = yyloc_default;
1523
+
1524
+ /* Number of syntax errors so far. */
1525
+ int yynerrs;
1526
+
1527
+ int yystate;
1528
+ /* Number of tokens to shift before error messages enabled. */
1529
+ int yyerrstatus;
1530
+
1531
+ /* The stacks and their tools:
1532
+ 'yyss': related to states.
1533
+ 'yyvs': related to semantic values.
1534
+ 'yyls': related to locations.
1535
+
1536
+ Refer to the stacks through separate pointers, to allow yyoverflow
1537
+ to reallocate them elsewhere. */
1538
+
1539
+ /* The state stack. */
1540
+ yytype_int16 yyssa[YYINITDEPTH];
1541
+ yytype_int16 *yyss;
1542
+ yytype_int16 *yyssp;
1543
+
1544
+ /* The semantic value stack. */
1545
+ YYSTYPE yyvsa[YYINITDEPTH];
1546
+ YYSTYPE *yyvs;
1547
+ YYSTYPE *yyvsp;
1548
+
1549
+ /* The location stack. */
1550
+ YYLTYPE yylsa[YYINITDEPTH];
1551
+ YYLTYPE *yyls;
1552
+ YYLTYPE *yylsp;
1553
+
1554
+ /* The locations where the error started and ended. */
1555
+ YYLTYPE yyerror_range[3];
1556
+
1557
+ YYSIZE_T yystacksize;
1558
+
1559
+ int yyn;
1560
+ int yyresult;
1561
+ /* Lookahead token as an internal (translated) token number. */
1562
+ int yytoken = 0;
1563
+ /* The variables used to return semantic value and location from the
1564
+ action routines. */
1565
+ YYSTYPE yyval;
1566
+ YYLTYPE yyloc;
1567
+
1568
+ #if YYERROR_VERBOSE
1569
+ /* Buffer for error messages, and its allocated size. */
1570
+ char yymsgbuf[128];
1571
+ char *yymsg = yymsgbuf;
1572
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1573
+ #endif
1574
+
1575
+ #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1576
+
1577
+ /* The number of symbols on the RHS of the reduced rule.
1578
+ Keep to zero when no symbol should be popped. */
1579
+ int yylen = 0;
1580
+
1581
+ yyssp = yyss = yyssa;
1582
+ yyvsp = yyvs = yyvsa;
1583
+ yylsp = yyls = yylsa;
1584
+ yystacksize = YYINITDEPTH;
1585
+
1586
+ YYDPRINTF ((stderr, "Starting parse\n"));
1587
+
1588
+ yystate = 0;
1589
+ yyerrstatus = 0;
1590
+ yynerrs = 0;
1591
+ yychar = YYEMPTY; /* Cause a token to be read. */
1592
+
1593
+ /* User initialization code. */
1594
+ #line 315 "bpgrammar.y" /* yacc.c:1429 */
1595
+ {
1596
+ yylloc.first_line = 1;
1597
+ yylloc.first_column = 1;
1598
+ yylloc.last_line = 1;
1599
+ yylloc.last_column = 1;
1600
+ }
1601
+
1602
+ #line 1603 "bpgrammar.c" /* yacc.c:1429 */
1603
+ yylsp[0] = yylloc;
1604
+ goto yysetstate;
1605
+
1606
+ /*------------------------------------------------------------.
1607
+ | yynewstate -- Push a new state, which is found in yystate. |
1608
+ `------------------------------------------------------------*/
1609
+ yynewstate:
1610
+ /* In all cases, when you get here, the value and location stacks
1611
+ have just been pushed. So pushing a state here evens the stacks. */
1612
+ yyssp++;
1613
+
1614
+ yysetstate:
1615
+ *yyssp = yystate;
1616
+
1617
+ if (yyss + yystacksize - 1 <= yyssp)
1618
+ {
1619
+ /* Get the current used size of the three stacks, in elements. */
1620
+ YYSIZE_T yysize = yyssp - yyss + 1;
1621
+
1622
+ #ifdef yyoverflow
1623
+ {
1624
+ /* Give user a chance to reallocate the stack. Use copies of
1625
+ these so that the &'s don't force the real ones into
1626
+ memory. */
1627
+ YYSTYPE *yyvs1 = yyvs;
1628
+ yytype_int16 *yyss1 = yyss;
1629
+ YYLTYPE *yyls1 = yyls;
1630
+
1631
+ /* Each stack pointer address is followed by the size of the
1632
+ data in use in that stack, in bytes. This used to be a
1633
+ conditional around just the two extra args, but that might
1634
+ be undefined if yyoverflow is a macro. */
1635
+ yyoverflow (YY_("memory exhausted"),
1636
+ &yyss1, yysize * sizeof (*yyssp),
1637
+ &yyvs1, yysize * sizeof (*yyvsp),
1638
+ &yyls1, yysize * sizeof (*yylsp),
1639
+ &yystacksize);
1640
+
1641
+ yyls = yyls1;
1642
+ yyss = yyss1;
1643
+ yyvs = yyvs1;
1644
+ }
1645
+ #else /* no yyoverflow */
1646
+ # ifndef YYSTACK_RELOCATE
1647
+ goto yyexhaustedlab;
1648
+ # else
1649
+ /* Extend the stack our own way. */
1650
+ if (YYMAXDEPTH <= yystacksize)
1651
+ goto yyexhaustedlab;
1652
+ yystacksize *= 2;
1653
+ if (YYMAXDEPTH < yystacksize)
1654
+ yystacksize = YYMAXDEPTH;
1655
+
1656
+ {
1657
+ yytype_int16 *yyss1 = yyss;
1658
+ union yyalloc *yyptr =
1659
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1660
+ if (! yyptr)
1661
+ goto yyexhaustedlab;
1662
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
1663
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1664
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
1665
+ # undef YYSTACK_RELOCATE
1666
+ if (yyss1 != yyssa)
1667
+ YYSTACK_FREE (yyss1);
1668
+ }
1669
+ # endif
1670
+ #endif /* no yyoverflow */
1671
+
1672
+ yyssp = yyss + yysize - 1;
1673
+ yyvsp = yyvs + yysize - 1;
1674
+ yylsp = yyls + yysize - 1;
1675
+
1676
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1677
+ (unsigned long int) yystacksize));
1678
+
1679
+ if (yyss + yystacksize - 1 <= yyssp)
1680
+ YYABORT;
1681
+ }
1682
+
1683
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1684
+
1685
+ if (yystate == YYFINAL)
1686
+ YYACCEPT;
1687
+
1688
+ goto yybackup;
1689
+
1690
+ /*-----------.
1691
+ | yybackup. |
1692
+ `-----------*/
1693
+ yybackup:
1694
+
1695
+ /* Do appropriate processing given the current state. Read a
1696
+ lookahead token if we need one and don't already have one. */
1697
+
1698
+ /* First try to decide what to do without reference to lookahead token. */
1699
+ yyn = yypact[yystate];
1700
+ if (yypact_value_is_default (yyn))
1701
+ goto yydefault;
1702
+
1703
+ /* Not known => get a lookahead token if don't already have one. */
1704
+
1705
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1706
+ if (yychar == YYEMPTY)
1707
+ {
1708
+ YYDPRINTF ((stderr, "Reading a token: "));
1709
+ yychar = yylex (&yylval, &yylloc, scanner, ctx);
1710
+ }
1711
+
1712
+ if (yychar <= YYEOF)
1713
+ {
1714
+ yychar = yytoken = YYEOF;
1715
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
1716
+ }
1717
+ else
1718
+ {
1719
+ yytoken = YYTRANSLATE (yychar);
1720
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1721
+ }
1722
+
1723
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
1724
+ detect an error, take that action. */
1725
+ yyn += yytoken;
1726
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1727
+ goto yydefault;
1728
+ yyn = yytable[yyn];
1729
+ if (yyn <= 0)
1730
+ {
1731
+ if (yytable_value_is_error (yyn))
1732
+ goto yyerrlab;
1733
+ yyn = -yyn;
1734
+ goto yyreduce;
1735
+ }
1736
+
1737
+ /* Count tokens shifted since error; after three, turn off error
1738
+ status. */
1739
+ if (yyerrstatus)
1740
+ yyerrstatus--;
1741
+
1742
+ /* Shift the lookahead token. */
1743
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1744
+
1745
+ /* Discard the shifted token. */
1746
+ yychar = YYEMPTY;
1747
+
1748
+ yystate = yyn;
1749
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1750
+ *++yyvsp = yylval;
1751
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
1752
+ *++yylsp = yylloc;
1753
+ goto yynewstate;
1754
+
1755
+
1756
+ /*-----------------------------------------------------------.
1757
+ | yydefault -- do the default action for the current state. |
1758
+ `-----------------------------------------------------------*/
1759
+ yydefault:
1760
+ yyn = yydefact[yystate];
1761
+ if (yyn == 0)
1762
+ goto yyerrlab;
1763
+ goto yyreduce;
1764
+
1765
+
1766
+ /*-----------------------------.
1767
+ | yyreduce -- Do a reduction. |
1768
+ `-----------------------------*/
1769
+ yyreduce:
1770
+ /* yyn is the number of a rule to reduce with. */
1771
+ yylen = yyr2[yyn];
1772
+
1773
+ /* If YYLEN is nonzero, implement the default value of the action:
1774
+ '$$ = $1'.
1775
+
1776
+ Otherwise, the following line sets YYVAL to garbage.
1777
+ This behavior is undocumented and Bison
1778
+ users should not rely upon it. Assigning to YYVAL
1779
+ unconditionally makes the parser a bit smaller, and it avoids a
1780
+ GCC warning that YYVAL may be used uninitialized. */
1781
+ yyval = yyvsp[1-yylen];
1782
+
1783
+ /* Default location. */
1784
+ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1785
+ YY_REDUCE_PRINT (yyn);
1786
+ switch (yyn)
1787
+ {
1788
+ case 2:
1789
+ #line 379 "bpgrammar.y" /* yacc.c:1646 */
1790
+ { (yyval.ndt) = (yyvsp[-1].ndt); *ast = (yyval.ndt); YYACCEPT; }
1791
+ #line 1792 "bpgrammar.c" /* yacc.c:1646 */
1792
+ break;
1793
+
1794
+ case 3:
1795
+ #line 382 "bpgrammar.y" /* yacc.c:1646 */
1796
+ { (yyval.ndt) = make_dimensions((yyvsp[-2].string_seq), (yyvsp[0].ndt), ctx); if ((yyval.ndt) == NULL) YYABORT; }
1797
+ #line 1798 "bpgrammar.c" /* yacc.c:1646 */
1798
+ break;
1799
+
1800
+ case 4:
1801
+ #line 383 "bpgrammar.y" /* yacc.c:1646 */
1802
+ { (yyval.ndt) = (yyvsp[0].ndt); }
1803
+ #line 1804 "bpgrammar.c" /* yacc.c:1646 */
1804
+ break;
1805
+
1806
+ case 5:
1807
+ #line 384 "bpgrammar.y" /* yacc.c:1646 */
1808
+ { (yyval.ndt) = (yyvsp[0].ndt); }
1809
+ #line 1810 "bpgrammar.c" /* yacc.c:1646 */
1810
+ break;
1811
+
1812
+ case 6:
1813
+ #line 387 "bpgrammar.y" /* yacc.c:1646 */
1814
+ { (yyval.string_seq) = ndt_string_seq_new((yyvsp[0].string), ctx); if ((yyval.string_seq) == NULL) YYABORT; }
1815
+ #line 1816 "bpgrammar.c" /* yacc.c:1646 */
1816
+ break;
1817
+
1818
+ case 7:
1819
+ #line 388 "bpgrammar.y" /* yacc.c:1646 */
1820
+ { (yyval.string_seq) = ndt_string_seq_append((yyvsp[-2].string_seq), (yyvsp[0].string), ctx); if ((yyval.string_seq) == NULL) YYABORT; }
1821
+ #line 1822 "bpgrammar.c" /* yacc.c:1646 */
1822
+ break;
1823
+
1824
+ case 8:
1825
+ #line 391 "bpgrammar.y" /* yacc.c:1646 */
1826
+ { (yyval.ndt) = make_dtype((yyvsp[-1].uchar), (yyvsp[0].uchar), ctx); if ((yyval.ndt) == NULL) YYABORT; }
1827
+ #line 1828 "bpgrammar.c" /* yacc.c:1646 */
1828
+ break;
1829
+
1830
+ case 9:
1831
+ #line 392 "bpgrammar.y" /* yacc.c:1646 */
1832
+ { (yyval.ndt) = make_fixed_bytes((yyvsp[-1].string), ctx); if ((yyval.ndt) == NULL) YYABORT; }
1833
+ #line 1834 "bpgrammar.c" /* yacc.c:1646 */
1834
+ break;
1835
+
1836
+ case 10:
1837
+ #line 393 "bpgrammar.y" /* yacc.c:1646 */
1838
+ { (yyval.ndt) = (yyvsp[0].ndt); }
1839
+ #line 1840 "bpgrammar.c" /* yacc.c:1646 */
1840
+ break;
1841
+
1842
+ case 11:
1843
+ #line 396 "bpgrammar.y" /* yacc.c:1646 */
1844
+ { (yyval.ndt) = make_record((yyvsp[-1].field_seq), ctx); if ((yyval.ndt) == NULL) YYABORT; }
1845
+ #line 1846 "bpgrammar.c" /* yacc.c:1646 */
1846
+ break;
1847
+
1848
+ case 12:
1849
+ #line 399 "bpgrammar.y" /* yacc.c:1646 */
1850
+ { (yyval.field_seq) = ndt_field_seq_new((yyvsp[0].field), ctx); if ((yyval.field_seq) == NULL) YYABORT; }
1851
+ #line 1852 "bpgrammar.c" /* yacc.c:1646 */
1852
+ break;
1853
+
1854
+ case 13:
1855
+ #line 400 "bpgrammar.y" /* yacc.c:1646 */
1856
+ { (yyval.field_seq) = ndt_field_seq_append((yyvsp[-1].field_seq), (yyvsp[0].field), ctx); if ((yyval.field_seq) == NULL) YYABORT; }
1857
+ #line 1858 "bpgrammar.c" /* yacc.c:1646 */
1858
+ break;
1859
+
1860
+ case 14:
1861
+ #line 403 "bpgrammar.y" /* yacc.c:1646 */
1862
+ { (yyval.field) = make_field((yyvsp[-2].string), (yyvsp[-4].ndt), (yyvsp[0].uint16), ctx); if ((yyval.field) == NULL) YYABORT; }
1863
+ #line 1864 "bpgrammar.c" /* yacc.c:1646 */
1864
+ break;
1865
+
1866
+ case 15:
1867
+ #line 406 "bpgrammar.y" /* yacc.c:1646 */
1868
+ { (yyval.ndt) = mk_function((yyvsp[-2].type_seq), (yyvsp[0].type_seq), ctx); if ((yyval.ndt) == NULL) YYABORT; }
1869
+ #line 1870 "bpgrammar.c" /* yacc.c:1646 */
1870
+ break;
1871
+
1872
+ case 16:
1873
+ #line 409 "bpgrammar.y" /* yacc.c:1646 */
1874
+ { (yyval.type_seq) = broadcast_seq_new((yyvsp[0].ndt), ctx); if ((yyval.type_seq) == NULL) YYABORT; }
1875
+ #line 1876 "bpgrammar.c" /* yacc.c:1646 */
1876
+ break;
1877
+
1878
+ case 17:
1879
+ #line 410 "bpgrammar.y" /* yacc.c:1646 */
1880
+ { (yyval.type_seq) = broadcast_seq_append((yyvsp[-1].type_seq), (yyvsp[0].ndt), ctx); if ((yyval.type_seq) == NULL) YYABORT; }
1881
+ #line 1882 "bpgrammar.c" /* yacc.c:1646 */
1882
+ break;
1883
+
1884
+ case 18:
1885
+ #line 413 "bpgrammar.y" /* yacc.c:1646 */
1886
+ { (yyval.uchar) = '@'; }
1887
+ #line 1888 "bpgrammar.c" /* yacc.c:1646 */
1888
+ break;
1889
+
1890
+ case 19:
1891
+ #line 414 "bpgrammar.y" /* yacc.c:1646 */
1892
+ { (yyval.uchar) = '@'; }
1893
+ #line 1894 "bpgrammar.c" /* yacc.c:1646 */
1894
+ break;
1895
+
1896
+ case 20:
1897
+ #line 415 "bpgrammar.y" /* yacc.c:1646 */
1898
+ { (yyval.uchar) = '='; }
1899
+ #line 1900 "bpgrammar.c" /* yacc.c:1646 */
1900
+ break;
1901
+
1902
+ case 21:
1903
+ #line 416 "bpgrammar.y" /* yacc.c:1646 */
1904
+ { (yyval.uchar) = '<'; }
1905
+ #line 1906 "bpgrammar.c" /* yacc.c:1646 */
1906
+ break;
1907
+
1908
+ case 22:
1909
+ #line 417 "bpgrammar.y" /* yacc.c:1646 */
1910
+ { (yyval.uchar) = '>'; }
1911
+ #line 1912 "bpgrammar.c" /* yacc.c:1646 */
1912
+ break;
1913
+
1914
+ case 23:
1915
+ #line 418 "bpgrammar.y" /* yacc.c:1646 */
1916
+ { (yyval.uchar) = '!'; }
1917
+ #line 1918 "bpgrammar.c" /* yacc.c:1646 */
1918
+ break;
1919
+
1920
+ case 24:
1921
+ #line 421 "bpgrammar.y" /* yacc.c:1646 */
1922
+ { (yyval.string) = NULL; }
1923
+ #line 1924 "bpgrammar.c" /* yacc.c:1646 */
1924
+ break;
1925
+
1926
+ case 25:
1927
+ #line 422 "bpgrammar.y" /* yacc.c:1646 */
1928
+ { (yyval.string) = (yyvsp[0].string); if ((yyval.string) == NULL) YYABORT; }
1929
+ #line 1930 "bpgrammar.c" /* yacc.c:1646 */
1930
+ break;
1931
+
1932
+ case 26:
1933
+ #line 425 "bpgrammar.y" /* yacc.c:1646 */
1934
+ { (yyval.uint16) = 0; }
1935
+ #line 1936 "bpgrammar.c" /* yacc.c:1646 */
1936
+ break;
1937
+
1938
+ case 27:
1939
+ #line 426 "bpgrammar.y" /* yacc.c:1646 */
1940
+ { (yyval.uint16) = add_uint16((yyvsp[-1].uint16), 1, ctx); if (ndt_err_occurred(ctx)) YYABORT; }
1941
+ #line 1942 "bpgrammar.c" /* yacc.c:1646 */
1942
+ break;
1943
+
1944
+
1945
+ #line 1946 "bpgrammar.c" /* yacc.c:1646 */
1946
+ default: break;
1947
+ }
1948
+ /* User semantic actions sometimes alter yychar, and that requires
1949
+ that yytoken be updated with the new translation. We take the
1950
+ approach of translating immediately before every use of yytoken.
1951
+ One alternative is translating here after every semantic action,
1952
+ but that translation would be missed if the semantic action invokes
1953
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1954
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1955
+ incorrect destructor might then be invoked immediately. In the
1956
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
1957
+ to an incorrect destructor call or verbose syntax error message
1958
+ before the lookahead is translated. */
1959
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1960
+
1961
+ YYPOPSTACK (yylen);
1962
+ yylen = 0;
1963
+ YY_STACK_PRINT (yyss, yyssp);
1964
+
1965
+ *++yyvsp = yyval;
1966
+ *++yylsp = yyloc;
1967
+
1968
+ /* Now 'shift' the result of the reduction. Determine what state
1969
+ that goes to, based on the state we popped back to and the rule
1970
+ number reduced by. */
1971
+
1972
+ yyn = yyr1[yyn];
1973
+
1974
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1975
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1976
+ yystate = yytable[yystate];
1977
+ else
1978
+ yystate = yydefgoto[yyn - YYNTOKENS];
1979
+
1980
+ goto yynewstate;
1981
+
1982
+
1983
+ /*--------------------------------------.
1984
+ | yyerrlab -- here on detecting error. |
1985
+ `--------------------------------------*/
1986
+ yyerrlab:
1987
+ /* Make sure we have latest lookahead translation. See comments at
1988
+ user semantic actions for why this is necessary. */
1989
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1990
+
1991
+ /* If not already recovering from an error, report this error. */
1992
+ if (!yyerrstatus)
1993
+ {
1994
+ ++yynerrs;
1995
+ #if ! YYERROR_VERBOSE
1996
+ yyerror (&yylloc, scanner, ast, ctx, YY_("syntax error"));
1997
+ #else
1998
+ # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1999
+ yyssp, yytoken)
2000
+ {
2001
+ char const *yymsgp = YY_("syntax error");
2002
+ int yysyntax_error_status;
2003
+ yysyntax_error_status = YYSYNTAX_ERROR;
2004
+ if (yysyntax_error_status == 0)
2005
+ yymsgp = yymsg;
2006
+ else if (yysyntax_error_status == 1)
2007
+ {
2008
+ if (yymsg != yymsgbuf)
2009
+ YYSTACK_FREE (yymsg);
2010
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2011
+ if (!yymsg)
2012
+ {
2013
+ yymsg = yymsgbuf;
2014
+ yymsg_alloc = sizeof yymsgbuf;
2015
+ yysyntax_error_status = 2;
2016
+ }
2017
+ else
2018
+ {
2019
+ yysyntax_error_status = YYSYNTAX_ERROR;
2020
+ yymsgp = yymsg;
2021
+ }
2022
+ }
2023
+ yyerror (&yylloc, scanner, ast, ctx, yymsgp);
2024
+ if (yysyntax_error_status == 2)
2025
+ goto yyexhaustedlab;
2026
+ }
2027
+ # undef YYSYNTAX_ERROR
2028
+ #endif
2029
+ }
2030
+
2031
+ yyerror_range[1] = yylloc;
2032
+
2033
+ if (yyerrstatus == 3)
2034
+ {
2035
+ /* If just tried and failed to reuse lookahead token after an
2036
+ error, discard it. */
2037
+
2038
+ if (yychar <= YYEOF)
2039
+ {
2040
+ /* Return failure if at end of input. */
2041
+ if (yychar == YYEOF)
2042
+ YYABORT;
2043
+ }
2044
+ else
2045
+ {
2046
+ yydestruct ("Error: discarding",
2047
+ yytoken, &yylval, &yylloc, scanner, ast, ctx);
2048
+ yychar = YYEMPTY;
2049
+ }
2050
+ }
2051
+
2052
+ /* Else will try to reuse lookahead token after shifting the error
2053
+ token. */
2054
+ goto yyerrlab1;
2055
+
2056
+
2057
+ /*---------------------------------------------------.
2058
+ | yyerrorlab -- error raised explicitly by YYERROR. |
2059
+ `---------------------------------------------------*/
2060
+ yyerrorlab:
2061
+
2062
+ /* Pacify compilers like GCC when the user code never invokes
2063
+ YYERROR and the label yyerrorlab therefore never appears in user
2064
+ code. */
2065
+ if (/*CONSTCOND*/ 0)
2066
+ goto yyerrorlab;
2067
+
2068
+ yyerror_range[1] = yylsp[1-yylen];
2069
+ /* Do not reclaim the symbols of the rule whose action triggered
2070
+ this YYERROR. */
2071
+ YYPOPSTACK (yylen);
2072
+ yylen = 0;
2073
+ YY_STACK_PRINT (yyss, yyssp);
2074
+ yystate = *yyssp;
2075
+ goto yyerrlab1;
2076
+
2077
+
2078
+ /*-------------------------------------------------------------.
2079
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |
2080
+ `-------------------------------------------------------------*/
2081
+ yyerrlab1:
2082
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
2083
+
2084
+ for (;;)
2085
+ {
2086
+ yyn = yypact[yystate];
2087
+ if (!yypact_value_is_default (yyn))
2088
+ {
2089
+ yyn += YYTERROR;
2090
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2091
+ {
2092
+ yyn = yytable[yyn];
2093
+ if (0 < yyn)
2094
+ break;
2095
+ }
2096
+ }
2097
+
2098
+ /* Pop the current state because it cannot handle the error token. */
2099
+ if (yyssp == yyss)
2100
+ YYABORT;
2101
+
2102
+ yyerror_range[1] = *yylsp;
2103
+ yydestruct ("Error: popping",
2104
+ yystos[yystate], yyvsp, yylsp, scanner, ast, ctx);
2105
+ YYPOPSTACK (1);
2106
+ yystate = *yyssp;
2107
+ YY_STACK_PRINT (yyss, yyssp);
2108
+ }
2109
+
2110
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2111
+ *++yyvsp = yylval;
2112
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
2113
+
2114
+ yyerror_range[2] = yylloc;
2115
+ /* Using YYLLOC is tempting, but would change the location of
2116
+ the lookahead. YYLOC is available though. */
2117
+ YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
2118
+ *++yylsp = yyloc;
2119
+
2120
+ /* Shift the error token. */
2121
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2122
+
2123
+ yystate = yyn;
2124
+ goto yynewstate;
2125
+
2126
+
2127
+ /*-------------------------------------.
2128
+ | yyacceptlab -- YYACCEPT comes here. |
2129
+ `-------------------------------------*/
2130
+ yyacceptlab:
2131
+ yyresult = 0;
2132
+ goto yyreturn;
2133
+
2134
+ /*-----------------------------------.
2135
+ | yyabortlab -- YYABORT comes here. |
2136
+ `-----------------------------------*/
2137
+ yyabortlab:
2138
+ yyresult = 1;
2139
+ goto yyreturn;
2140
+
2141
+ #if !defined yyoverflow || YYERROR_VERBOSE
2142
+ /*-------------------------------------------------.
2143
+ | yyexhaustedlab -- memory exhaustion comes here. |
2144
+ `-------------------------------------------------*/
2145
+ yyexhaustedlab:
2146
+ yyerror (&yylloc, scanner, ast, ctx, YY_("memory exhausted"));
2147
+ yyresult = 2;
2148
+ /* Fall through. */
2149
+ #endif
2150
+
2151
+ yyreturn:
2152
+ if (yychar != YYEMPTY)
2153
+ {
2154
+ /* Make sure we have latest lookahead translation. See comments at
2155
+ user semantic actions for why this is necessary. */
2156
+ yytoken = YYTRANSLATE (yychar);
2157
+ yydestruct ("Cleanup: discarding lookahead",
2158
+ yytoken, &yylval, &yylloc, scanner, ast, ctx);
2159
+ }
2160
+ /* Do not reclaim the symbols of the rule whose action triggered
2161
+ this YYABORT or YYACCEPT. */
2162
+ YYPOPSTACK (yylen);
2163
+ YY_STACK_PRINT (yyss, yyssp);
2164
+ while (yyssp != yyss)
2165
+ {
2166
+ yydestruct ("Cleanup: popping",
2167
+ yystos[*yyssp], yyvsp, yylsp, scanner, ast, ctx);
2168
+ YYPOPSTACK (1);
2169
+ }
2170
+ #ifndef yyoverflow
2171
+ if (yyss != yyssa)
2172
+ YYSTACK_FREE (yyss);
2173
+ #endif
2174
+ #if YYERROR_VERBOSE
2175
+ if (yymsg != yymsgbuf)
2176
+ YYSTACK_FREE (yymsg);
2177
+ #endif
2178
+ return yyresult;
2179
+ }