1 |
|
2 |
|
3 | (function () {
|
4 | function id(x) { return x[0]; }
|
5 |
|
6 | const lexer = require('./lex').lexer;
|
7 | const util = require('./parser-util');
|
8 | var grammar = {
|
9 | Lexer: lexer,
|
10 | ParserRules: [
|
11 | {"name": "Expression", "symbols": ["Exp0"], "postprocess": id},
|
12 | {"name": "Identifier", "symbols": [(lexer.has("identifier") ? {type: "identifier"} : identifier)], "postprocess": util.Identifier},
|
13 | {"name": "TypeIdentifier", "symbols": [(lexer.has("type_identifier") ? {type: "type_identifier"} : type_identifier)], "postprocess": util.Identifier},
|
14 | {"name": "StructName", "symbols": [(lexer.has("identifier") ? {type: "identifier"} : identifier)], "postprocess": util.Identifier},
|
15 | {"name": "StructName", "symbols": [(lexer.has("type_identifier") ? {type: "type_identifier"} : type_identifier)], "postprocess": util.Identifier},
|
16 | {"name": "FieldName", "symbols": [(lexer.has("identifier") ? {type: "identifier"} : identifier)], "postprocess": util.Identifier},
|
17 | {"name": "FieldName", "symbols": [(lexer.has("type_identifier") ? {type: "type_identifier"} : type_identifier)], "postprocess": util.Identifier},
|
18 | {"name": "Unop", "symbols": [{"literal":"!"}]},
|
19 | {"name": "Unop", "symbols": [{"literal":"~"}]},
|
20 | {"name": "Unop", "symbols": [{"literal":"-"}]},
|
21 | {"name": "Unop", "symbols": [{"literal":"*"}]},
|
22 | {"name": "Unop", "symbols": [{"literal":"&"}]},
|
23 | {"name": "Unop", "symbols": [{"literal":"("}, "_", "Tp", "_", {"literal":")"}]},
|
24 | {"name": "BinopB", "symbols": [{"literal":"*"}]},
|
25 | {"name": "BinopB", "symbols": [{"literal":"/"}]},
|
26 | {"name": "BinopB", "symbols": [{"literal":"%"}]},
|
27 | {"name": "BinopA", "symbols": [{"literal":"+"}]},
|
28 | {"name": "BinopA", "symbols": [{"literal":"-"}]},
|
29 | {"name": "Binop9", "symbols": [{"literal":"<"}, {"literal":"<"}]},
|
30 | {"name": "Binop9", "symbols": [{"literal":">"}, {"literal":">"}]},
|
31 | {"name": "Binop8", "symbols": [{"literal":"<"}]},
|
32 | {"name": "Binop8", "symbols": [{"literal":"<"}, {"literal":"="}]},
|
33 | {"name": "Binop8", "symbols": [{"literal":">"}, {"literal":"="}]},
|
34 | {"name": "Binop8", "symbols": [{"literal":">"}]},
|
35 | {"name": "Binop7", "symbols": [{"literal":"="}, {"literal":"="}]},
|
36 | {"name": "Binop7", "symbols": [{"literal":"!"}, {"literal":"="}]},
|
37 | {"name": "Binop6", "symbols": [{"literal":"&"}]},
|
38 | {"name": "Binop5", "symbols": [{"literal":"^"}]},
|
39 | {"name": "Binop4", "symbols": [{"literal":"|"}]},
|
40 | {"name": "Binop3", "symbols": [{"literal":"&&"}]},
|
41 | {"name": "Binop2", "symbols": [{"literal":"|"}, {"literal":"|"}]},
|
42 | {"name": "Binop1", "symbols": [{"literal":"?"}]},
|
43 | {"name": "Binop0", "symbols": [{"literal":"="}]},
|
44 | {"name": "Binop0", "symbols": [{"literal":"+"}, {"literal":"="}]},
|
45 | {"name": "Binop0", "symbols": [{"literal":"-"}, {"literal":"="}]},
|
46 | {"name": "Binop0", "symbols": [{"literal":"*"}, {"literal":"="}]},
|
47 | {"name": "Binop0", "symbols": [{"literal":"/"}, {"literal":"="}]},
|
48 | {"name": "Binop0", "symbols": [{"literal":"%"}, {"literal":"="}]},
|
49 | {"name": "Binop0", "symbols": [{"literal":"&"}, {"literal":"="}]},
|
50 | {"name": "Binop0", "symbols": [{"literal":"^"}, {"literal":"="}]},
|
51 | {"name": "Binop0", "symbols": [{"literal":"|"}, {"literal":"="}]},
|
52 | {"name": "Binop0", "symbols": [{"literal":"<"}, {"literal":"<"}, {"literal":"="}]},
|
53 | {"name": "Binop0", "symbols": [{"literal":">"}, {"literal":">"}, {"literal":"="}]},
|
54 | {"name": "ExpD", "symbols": [{"literal":"("}, "_", "Expression", "_", {"literal":")"}], "postprocess": x => x[2]},
|
55 | {"name": "ExpD", "symbols": [(lexer.has("numeric_literal") ? {type: "numeric_literal"} : numeric_literal)], "postprocess": util.IntLiteral},
|
56 | {"name": "ExpD", "symbols": ["StringLiteral"], "postprocess": util.StringLiteral},
|
57 | {"name": "ExpD", "symbols": ["CharLiteral"], "postprocess": util.CharLiteral},
|
58 | {"name": "ExpD", "symbols": [{"literal":"true"}], "postprocess": util.BoolLiteral},
|
59 | {"name": "ExpD", "symbols": [{"literal":"false"}], "postprocess": util.BoolLiteral},
|
60 | {"name": "ExpD", "symbols": [{"literal":"NULL"}], "postprocess": util.NullLiteral},
|
61 | {"name": "ExpD", "symbols": ["Identifier"], "postprocess": id},
|
62 | {"name": "ExpD", "symbols": ["Identifier", "_", "Funargs"], "postprocess": util.CallExpression},
|
63 | {"name": "ExpD", "symbols": ["ExpD", "_", {"literal":"."}, "_", "FieldName"], "postprocess": util.StructMemberExpression},
|
64 | {"name": "ExpD$subexpression$1", "symbols": [{"literal":"-"}, {"literal":">"}]},
|
65 | {"name": "ExpD", "symbols": ["ExpD", "_", "ExpD$subexpression$1", "_", "FieldName"], "postprocess": util.StructMemberExpression},
|
66 | {"name": "ExpD", "symbols": ["ExpD", "_", {"literal":"["}, "_", "Expression", "_", {"literal":"]"}], "postprocess": util.ArrayMemberExpression},
|
67 | {"name": "ExpD", "symbols": ["ExpD", "_", {"literal":"+"}, {"literal":"+"}], "postprocess": util.UpdateExpression},
|
68 | {"name": "ExpD", "symbols": ["ExpD", "_", {"literal":"-"}, {"literal":"-"}], "postprocess": util.UpdateExpression},
|
69 | {"name": "ExpD", "symbols": [{"literal":"alloc"}, "_", {"literal":"("}, "_", "Tp", "_", {"literal":")"}], "postprocess": util.AllocExpression},
|
70 | {"name": "ExpD", "symbols": [{"literal":"alloc_array"}, "_", {"literal":"("}, "_", "Tp", "_", {"literal":","}, "_", "Expression", "_", {"literal":")"}], "postprocess": util.AllocArrayExpression},
|
71 | {"name": "ExpD", "symbols": [{"literal":"assert"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}], "postprocess": util.AssertExpression},
|
72 | {"name": "ExpD", "symbols": [{"literal":"error"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}], "postprocess": util.ErrorExpression},
|
73 | {"name": "ExpD", "symbols": [{"literal":"\\"}, {"literal":"result"}], "postprocess": util.ResultExpression},
|
74 | {"name": "ExpD", "symbols": [{"literal":"\\"}, {"literal":"length"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}], "postprocess": util.LengthExpression},
|
75 | {"name": "ExpD", "symbols": [{"literal":"\\"}, {"literal":"hastag"}, "_", {"literal":"("}, "_", "Tp", "_", {"literal":","}, "_", "Expression", "_", {"literal":")"}], "postprocess": util.HasTagExpression},
|
76 | {"name": "ExpD", "symbols": [{"literal":"("}, "_", {"literal":"*"}, "_", "Expression", "_", {"literal":")"}, "_", "Funargs"], "postprocess": util.IndirectCallExpression},
|
77 | {"name": "ExpC", "symbols": ["ExpD"], "postprocess": id},
|
78 | {"name": "ExpC", "symbols": ["Unop", "_", "ExpC"], "postprocess": util.UnaryExpression},
|
79 | {"name": "ExpB", "symbols": ["ExpC"], "postprocess": id},
|
80 | {"name": "ExpB", "symbols": ["ExpC", "_", "BinopB", "_", "ExpB"], "postprocess": util.BinaryExpression},
|
81 | {"name": "ExpA", "symbols": ["ExpB"], "postprocess": id},
|
82 | {"name": "ExpA", "symbols": ["ExpB", "_", "BinopA", "_", "ExpA"], "postprocess": util.BinaryExpression},
|
83 | {"name": "Exp9", "symbols": ["ExpA"], "postprocess": id},
|
84 | {"name": "Exp9", "symbols": ["ExpA", "_", "Binop9", "_", "Exp9"], "postprocess": util.BinaryExpression},
|
85 | {"name": "Exp8", "symbols": ["Exp9"], "postprocess": id},
|
86 | {"name": "Exp8", "symbols": ["Exp9", "_", "Binop8", "_", "Exp8"], "postprocess": util.BinaryExpression},
|
87 | {"name": "Exp7", "symbols": ["Exp8"], "postprocess": id},
|
88 | {"name": "Exp7", "symbols": ["Exp8", "_", "Binop7", "_", "Exp7"], "postprocess": util.BinaryExpression},
|
89 | {"name": "Exp6", "symbols": ["Exp7"], "postprocess": id},
|
90 | {"name": "Exp6", "symbols": ["Exp7", "_", "Binop6", "_", "Exp6"], "postprocess": util.BinaryExpression},
|
91 | {"name": "Exp5", "symbols": ["Exp6"], "postprocess": id},
|
92 | {"name": "Exp5", "symbols": ["Exp6", "_", "Binop5", "_", "Exp5"], "postprocess": util.BinaryExpression},
|
93 | {"name": "Exp4", "symbols": ["Exp5"], "postprocess": id},
|
94 | {"name": "Exp4", "symbols": ["Exp5", "_", "Binop4", "_", "Exp4"], "postprocess": util.BinaryExpression},
|
95 | {"name": "Exp3", "symbols": ["Exp4"], "postprocess": id},
|
96 | {"name": "Exp3", "symbols": ["Exp4", "_", "Binop3", "_", "Exp3"], "postprocess": util.BinaryExpression},
|
97 | {"name": "Exp2", "symbols": ["Exp3"], "postprocess": id},
|
98 | {"name": "Exp2", "symbols": ["Exp3", "_", "Binop2", "_", "Exp2"], "postprocess": util.BinaryExpression},
|
99 | {"name": "Exp1", "symbols": ["Exp2"], "postprocess": id},
|
100 | {"name": "Exp1", "symbols": ["Exp2", "_", "Binop1", "_", "Expression", "_", {"literal":":"}, "_", "Exp1"], "postprocess": util.ConditionalExpression},
|
101 | {"name": "Exp0", "symbols": ["Exp1"], "postprocess": id},
|
102 | {"name": "Exp0", "symbols": ["Exp1", "_", "Binop0", "_", "Exp0"], "postprocess": util.BinaryExpression},
|
103 | {"name": "Funargs$ebnf$1$subexpression$1$ebnf$1", "symbols": []},
|
104 | {"name": "Funargs$ebnf$1$subexpression$1$ebnf$1$subexpression$1", "symbols": [{"literal":","}, "_", "Expression"]},
|
105 | {"name": "Funargs$ebnf$1$subexpression$1$ebnf$1", "symbols": ["Funargs$ebnf$1$subexpression$1$ebnf$1", "Funargs$ebnf$1$subexpression$1$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
106 | {"name": "Funargs$ebnf$1$subexpression$1", "symbols": ["Expression", "_", "Funargs$ebnf$1$subexpression$1$ebnf$1"]},
|
107 | {"name": "Funargs$ebnf$1", "symbols": ["Funargs$ebnf$1$subexpression$1"], "postprocess": id},
|
108 | {"name": "Funargs$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
|
109 | {"name": "Funargs", "symbols": [{"literal":"("}, "_", "Funargs$ebnf$1", {"literal":")"}]},
|
110 | {"name": "Tp", "symbols": [{"literal":"int"}], "postprocess": util.IntType},
|
111 | {"name": "Tp", "symbols": [{"literal":"bool"}], "postprocess": util.BoolType},
|
112 | {"name": "Tp", "symbols": [{"literal":"string"}], "postprocess": util.StringType},
|
113 | {"name": "Tp", "symbols": [{"literal":"char"}], "postprocess": util.CharType},
|
114 | {"name": "Tp", "symbols": [{"literal":"void"}], "postprocess": util.VoidType},
|
115 | {"name": "Tp", "symbols": ["Tp", "_", {"literal":"*"}], "postprocess": util.PointerType},
|
116 | {"name": "Tp", "symbols": ["Tp", "_", {"literal":"["}, "_", {"literal":"]"}], "postprocess": util.ArrayType},
|
117 | {"name": "Tp", "symbols": [{"literal":"struct"}, "_", "StructName"], "postprocess": util.StructType},
|
118 | {"name": "Tp", "symbols": ["TypeIdentifier"], "postprocess": id},
|
119 | {"name": "StringLiteral$ebnf$1", "symbols": []},
|
120 | {"name": "StringLiteral$ebnf$1$subexpression$1", "symbols": [(lexer.has("special_character") ? {type: "special_character"} : special_character)]},
|
121 | {"name": "StringLiteral$ebnf$1$subexpression$1", "symbols": [(lexer.has("characters") ? {type: "characters"} : characters)]},
|
122 | {"name": "StringLiteral$ebnf$1", "symbols": ["StringLiteral$ebnf$1", "StringLiteral$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
123 | {"name": "StringLiteral", "symbols": [(lexer.has("string_delimiter") ? {type: "string_delimiter"} : string_delimiter), "StringLiteral$ebnf$1", (lexer.has("string_delimiter") ? {type: "string_delimiter"} : string_delimiter)]},
|
124 | {"name": "CharLiteral$subexpression$1", "symbols": [(lexer.has("special_character") ? {type: "special_character"} : special_character)]},
|
125 | {"name": "CharLiteral$subexpression$1", "symbols": [(lexer.has("character") ? {type: "character"} : character)]},
|
126 | {"name": "CharLiteral", "symbols": [(lexer.has("char_delimiter") ? {type: "char_delimiter"} : char_delimiter), "CharLiteral$subexpression$1", (lexer.has("char_delimiter") ? {type: "char_delimiter"} : char_delimiter)]},
|
127 | {"name": "_$ebnf$1", "symbols": []},
|
128 | {"name": "_$ebnf$1$subexpression$1", "symbols": [(lexer.has("whitespace") ? {type: "whitespace"} : whitespace)]},
|
129 | {"name": "_$ebnf$1$subexpression$1", "symbols": [(lexer.has("newline") ? {type: "newline"} : newline)]},
|
130 | {"name": "_$ebnf$1$subexpression$1", "symbols": [(lexer.has("annospace") ? {type: "annospace"} : annospace)]},
|
131 | {"name": "_$ebnf$1$subexpression$1", "symbols": ["LineComment"]},
|
132 | {"name": "_$ebnf$1$subexpression$1", "symbols": ["MultiComment"]},
|
133 | {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", "_$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
134 | {"name": "_", "symbols": ["_$ebnf$1"]},
|
135 | {"name": "LineComment$ebnf$1", "symbols": []},
|
136 | {"name": "LineComment$ebnf$1", "symbols": ["LineComment$ebnf$1", (lexer.has("comment") ? {type: "comment"} : comment)], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
137 | {"name": "LineComment", "symbols": [(lexer.has("comment_line_start") ? {type: "comment_line_start"} : comment_line_start), "LineComment$ebnf$1", (lexer.has("comment_line_end") ? {type: "comment_line_end"} : comment_line_end)]},
|
138 | {"name": "MultiComment$ebnf$1", "symbols": []},
|
139 | {"name": "MultiComment$ebnf$1$subexpression$1", "symbols": [(lexer.has("comment") ? {type: "comment"} : comment)]},
|
140 | {"name": "MultiComment$ebnf$1$subexpression$1", "symbols": [(lexer.has("newline") ? {type: "newline"} : newline)]},
|
141 | {"name": "MultiComment$ebnf$1$subexpression$1", "symbols": ["MultiComment"]},
|
142 | {"name": "MultiComment$ebnf$1", "symbols": ["MultiComment$ebnf$1", "MultiComment$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
143 | {"name": "MultiComment", "symbols": [(lexer.has("comment_start") ? {type: "comment_start"} : comment_start), "MultiComment$ebnf$1", (lexer.has("comment_end") ? {type: "comment_end"} : comment_end)]},
|
144 | {"name": "Statement", "symbols": ["Annos_", "DanglingIf"]},
|
145 | {"name": "Statement", "symbols": ["Annos_", "NoDanglingIf"]},
|
146 | {"name": "NoDanglingIf", "symbols": ["Simple", "_", {"literal":";"}], "postprocess": util.SimpleStatement},
|
147 | {"name": "NoDanglingIf", "symbols": [{"literal":"while"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}, "_Annos", "_", "NoDanglingIf"], "postprocess": util.WhileStatement},
|
148 | {"name": "NoDanglingIf$ebnf$1$subexpression$1", "symbols": ["_", "Simple"]},
|
149 | {"name": "NoDanglingIf$ebnf$1", "symbols": ["NoDanglingIf$ebnf$1$subexpression$1"], "postprocess": id},
|
150 | {"name": "NoDanglingIf$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
|
151 | {"name": "NoDanglingIf$ebnf$2$subexpression$1", "symbols": ["_", "Expression"]},
|
152 | {"name": "NoDanglingIf$ebnf$2", "symbols": ["NoDanglingIf$ebnf$2$subexpression$1"], "postprocess": id},
|
153 | {"name": "NoDanglingIf$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
|
154 | {"name": "NoDanglingIf", "symbols": [{"literal":"for"}, "_", {"literal":"("}, "NoDanglingIf$ebnf$1", "_", {"literal":";"}, "_", "Expression", "_", {"literal":";"}, "NoDanglingIf$ebnf$2", "_", {"literal":")"}, "_Annos", "_", "NoDanglingIf"], "postprocess": util.ForStatement},
|
155 | {"name": "NoDanglingIf", "symbols": [{"literal":"if"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}, "_Annos", "_", "NoDanglingIf", "_", {"literal":"else"}, "_Annos", "_", "NoDanglingIf"], "postprocess": util.IfElseStatement},
|
156 | {"name": "NoDanglingIf$ebnf$3$subexpression$1", "symbols": ["_", "Expression"]},
|
157 | {"name": "NoDanglingIf$ebnf$3", "symbols": ["NoDanglingIf$ebnf$3$subexpression$1"], "postprocess": id},
|
158 | {"name": "NoDanglingIf$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
|
159 | {"name": "NoDanglingIf", "symbols": [{"literal":"return"}, "NoDanglingIf$ebnf$3", "_", {"literal":";"}], "postprocess": util.ReturnStatement},
|
160 | {"name": "NoDanglingIf", "symbols": ["StatementBlock"], "postprocess": id},
|
161 | {"name": "NoDanglingIf", "symbols": [{"literal":"break"}, "_", {"literal":";"}], "postprocess": util.BreakStatement},
|
162 | {"name": "NoDanglingIf", "symbols": [{"literal":"continue"}, "_", {"literal":";"}], "postprocess": util.ContinueStatement},
|
163 | {"name": "DanglingIf", "symbols": [{"literal":"while"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}, "_Annos", "_", "DanglingIf"], "postprocess": util.WhileStatement},
|
164 | {"name": "DanglingIf$ebnf$1$subexpression$1", "symbols": ["_", "Simple"]},
|
165 | {"name": "DanglingIf$ebnf$1", "symbols": ["DanglingIf$ebnf$1$subexpression$1"], "postprocess": id},
|
166 | {"name": "DanglingIf$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
|
167 | {"name": "DanglingIf$ebnf$2$subexpression$1", "symbols": ["_", "Expression"]},
|
168 | {"name": "DanglingIf$ebnf$2", "symbols": ["DanglingIf$ebnf$2$subexpression$1"], "postprocess": id},
|
169 | {"name": "DanglingIf$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
|
170 | {"name": "DanglingIf", "symbols": [{"literal":"for"}, "_", {"literal":"("}, "DanglingIf$ebnf$1", "_", {"literal":";"}, "_", "Expression", "_", {"literal":";"}, "DanglingIf$ebnf$2", "_", {"literal":")"}, "_Annos", "_", "DanglingIf"], "postprocess": util.ForStatement},
|
171 | {"name": "DanglingIf", "symbols": [{"literal":"if"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}, "_", "Statement"], "postprocess": util.IfStatement},
|
172 | {"name": "DanglingIf", "symbols": [{"literal":"if"}, "_", {"literal":"("}, "_", "Expression", "_", {"literal":")"}, "_Annos", "_", "NoDanglingIf", "_", {"literal":"else"}, "_Annos", "_", "DanglingIf"], "postprocess": util.IfElseStatement},
|
173 | {"name": "Simple$ebnf$1$subexpression$1", "symbols": ["_", {"literal":"="}, "_", "Expression"]},
|
174 | {"name": "Simple$ebnf$1", "symbols": ["Simple$ebnf$1$subexpression$1"], "postprocess": id},
|
175 | {"name": "Simple$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
|
176 | {"name": "Simple", "symbols": ["Tp", "_", "Identifier", "Simple$ebnf$1"]},
|
177 | {"name": "Simple", "symbols": ["Expression"], "postprocess": id},
|
178 | {"name": "StatementBlock$ebnf$1", "symbols": []},
|
179 | {"name": "StatementBlock$ebnf$1$subexpression$1", "symbols": ["_", "Statement"]},
|
180 | {"name": "StatementBlock$ebnf$1", "symbols": ["StatementBlock$ebnf$1", "StatementBlock$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
181 | {"name": "StatementBlock$ebnf$2", "symbols": []},
|
182 | {"name": "StatementBlock$ebnf$2$subexpression$1", "symbols": ["_", "Anno1"]},
|
183 | {"name": "StatementBlock$ebnf$2", "symbols": ["StatementBlock$ebnf$2", "StatementBlock$ebnf$2$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
184 | {"name": "StatementBlock", "symbols": [{"literal":"{"}, "StatementBlock$ebnf$1", "StatementBlock$ebnf$2", "_", {"literal":"}"}], "postprocess": util.BlockStatement},
|
185 | {"name": "Anno$subexpression$1", "symbols": [{"literal":"loop_invariant"}]},
|
186 | {"name": "Anno$subexpression$1", "symbols": [{"literal":"assert"}]},
|
187 | {"name": "Anno$subexpression$1", "symbols": [{"literal":"requires"}]},
|
188 | {"name": "Anno$subexpression$1", "symbols": [{"literal":"ensures"}]},
|
189 | {"name": "Anno", "symbols": ["Anno$subexpression$1", "_", "Expression", "_", {"literal":";"}], "postprocess": x => ({ tag: x[0][0].value, test: x[2] })},
|
190 | {"name": "Anno1$ebnf$1", "symbols": ["Anno"]},
|
191 | {"name": "Anno1$ebnf$1", "symbols": ["Anno1$ebnf$1", "Anno"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
192 | {"name": "Anno1", "symbols": [(lexer.has("anno_start") ? {type: "anno_start"} : anno_start), "_", "Anno1$ebnf$1", "_", (lexer.has("anno_end") ? {type: "anno_end"} : anno_end)], "postprocess": util.Anno1},
|
193 | {"name": "Anno1$ebnf$2", "symbols": ["Anno"]},
|
194 | {"name": "Anno1$ebnf$2", "symbols": ["Anno1$ebnf$2", "Anno"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
195 | {"name": "Anno1", "symbols": [(lexer.has("anno_line_start") ? {type: "anno_line_start"} : anno_line_start), "_", "Anno1$ebnf$2", "_", (lexer.has("anno_end") ? {type: "anno_end"} : anno_end)], "postprocess": util.Anno1},
|
196 | {"name": "Anno1$ebnf$3", "symbols": ["Anno"]},
|
197 | {"name": "Anno1$ebnf$3", "symbols": ["Anno1$ebnf$3", "Anno"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
198 | {"name": "Anno1$ebnf$4", "symbols": []},
|
199 | {"name": "Anno1$ebnf$4", "symbols": ["Anno1$ebnf$4", (lexer.has("comment") ? {type: "comment"} : comment)], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
200 | {"name": "Anno1", "symbols": [(lexer.has("anno_line_start") ? {type: "anno_line_start"} : anno_line_start), "_", "Anno1$ebnf$3", "_", (lexer.has("comment_line_start") ? {type: "comment_line_start"} : comment_line_start), "Anno1$ebnf$4", (lexer.has("comment_line_end") ? {type: "comment_line_end"} : comment_line_end)], "postprocess": util.Anno1},
|
201 | {"name": "Annos_$ebnf$1", "symbols": []},
|
202 | {"name": "Annos_$ebnf$1$subexpression$1", "symbols": ["Anno1", "_"]},
|
203 | {"name": "Annos_$ebnf$1", "symbols": ["Annos_$ebnf$1", "Annos_$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
204 | {"name": "Annos_", "symbols": ["Annos_$ebnf$1"], "postprocess": x => x[0].reduce((xs, y) => xs.concat(y[0]), [])},
|
205 | {"name": "_Annos$ebnf$1", "symbols": []},
|
206 | {"name": "_Annos$ebnf$1$subexpression$1", "symbols": ["_", "Anno1"]},
|
207 | {"name": "_Annos$ebnf$1", "symbols": ["_Annos$ebnf$1", "_Annos$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
208 | {"name": "_Annos", "symbols": ["_Annos$ebnf$1"], "postprocess": x => x[0].reduce((xs, y) => xs.concat(y[1]), [])},
|
209 | {"name": "Program$ebnf$1", "symbols": []},
|
210 | {"name": "Program$ebnf$1", "symbols": ["Program$ebnf$1", "_GlobalDecl"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
211 | {"name": "Program", "symbols": ["Program$ebnf$1", "_"], "postprocess": x => x[0]},
|
212 | {"name": "_GlobalDecl", "symbols": ["_", "GlobalDecl"], "postprocess": x => x[1]},
|
213 | {"name": "GlobalDecl", "symbols": [(lexer.has("pragma") ? {type: "pragma"} : pragma)]},
|
214 | {"name": "GlobalDecl", "symbols": [{"literal":"struct"}, "_", "StructName", "_", {"literal":";"}], "postprocess": x => `struct ${x[2].name} decl `},
|
215 | {"name": "GlobalDecl$ebnf$1", "symbols": []},
|
216 | {"name": "GlobalDecl$ebnf$1$subexpression$1", "symbols": ["Tp", "_", "FieldName", "_", {"literal":";"}, "_"]},
|
217 | {"name": "GlobalDecl$ebnf$1", "symbols": ["GlobalDecl$ebnf$1", "GlobalDecl$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
218 | {"name": "GlobalDecl", "symbols": [{"literal":"struct"}, "_", "StructName", "_", {"literal":"{"}, "_", "GlobalDecl$ebnf$1", {"literal":"}"}, "_", {"literal":";"}], "postprocess": x => `struct ${x[2].name} defn `},
|
219 | {"name": "GlobalDecl", "symbols": ["Tp", "_", "Identifier", "_", "FunDeclArgs", "_Annos", "_", "FunDeclEnd"], "postprocess": util.FunctionDeclaration},
|
220 | {"name": "GlobalDecl", "symbols": [{"literal":"typedef"}, "_", "Tp", "_", "Identifier"], "postprocess": x => [`define type ${x[4].name}`, x[4].name]},
|
221 | {"name": "GlobalDecl", "symbols": [{"literal":"typedef"}, "_", "Tp", "_", "Identifier", "_", "FunDeclArgs", "_Annos"], "postprocess": x => [`define function type ${x[4].name}`, x[4].name]},
|
222 | {"name": "FunDeclArgs$ebnf$1$subexpression$1$ebnf$1", "symbols": []},
|
223 | {"name": "FunDeclArgs$ebnf$1$subexpression$1$ebnf$1$subexpression$1", "symbols": [{"literal":","}, "_", "Tp", "_", "Identifier", "_"]},
|
224 | {"name": "FunDeclArgs$ebnf$1$subexpression$1$ebnf$1", "symbols": ["FunDeclArgs$ebnf$1$subexpression$1$ebnf$1", "FunDeclArgs$ebnf$1$subexpression$1$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
225 | {"name": "FunDeclArgs$ebnf$1$subexpression$1", "symbols": ["Tp", "_", "Identifier", "_", "FunDeclArgs$ebnf$1$subexpression$1$ebnf$1"]},
|
226 | {"name": "FunDeclArgs$ebnf$1", "symbols": ["FunDeclArgs$ebnf$1$subexpression$1"], "postprocess": id},
|
227 | {"name": "FunDeclArgs$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
|
228 | {"name": "FunDeclArgs", "symbols": [{"literal":"("}, "_", "FunDeclArgs$ebnf$1", {"literal":")"}], "postprocess": util.FunctionDeclarationArgs},
|
229 | {"name": "FunDeclEnd", "symbols": [{"literal":";"}], "postprocess": x => null},
|
230 | {"name": "FunDeclEnd", "symbols": ["StatementBlock"], "postprocess": id}
|
231 | ]
|
232 | , ParserStart: "Program"
|
233 | }
|
234 | if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
|
235 | module.exports = grammar;
|
236 | } else {
|
237 | window.grammar = grammar;
|
238 | }
|
239 | })();
|