yukigo-prolog-parser 0.1.3 → 0.2.2

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.
@@ -1,106 +1,59 @@
1
1
  // Generated automatically by nearley, version 2.20.1
2
2
  // http://github.com/Hardmath123/nearley
3
- // Bypasses TS6133. Allow declared but unused functions.
4
- // @ts-ignore
5
- function id(d: any[]): any { return d[0]; }
6
- declare var period: any;
7
- declare var testKeyword: any;
8
- declare var lparen: any;
9
- declare var rparen: any;
10
- declare var comma: any;
11
- declare var colonDash: any;
12
- declare var queryOp: any;
13
- declare var semicolon: any;
14
- declare var forallRule: any;
15
- declare var findallRule: any;
16
- declare var consOp: any;
17
- declare var wildcard: any;
18
- declare var variable: any;
19
- declare var atom: any;
20
- declare var primitiveOperator: any;
21
- declare var op: any;
22
- declare var comparisonOp: any;
23
- declare var number: any;
24
- declare var string: any;
25
- declare var WS: any;
26
- import {
27
- NumberPrimitive,
28
- StringPrimitive,
29
- Rule,
30
- Fact,
31
- Query,
32
- ListPrimitive,
33
- ConsExpression,
34
- ArithmeticBinaryOperation,
35
- ArithmeticUnaryOperation,
36
- ComparisonOperation,
37
- Exist,
38
- Not,
39
- Findall,
40
- Sequence,
41
- UnguardedBody,
42
- Equation,
43
- If,
44
- Call,
45
- Forall,
46
- SymbolPrimitive,
47
- AssignOperation,
48
- UnifyOperation,
49
- VariablePattern,
50
- FunctorPattern,
51
- ConsPattern,
52
- ListPattern,
53
- LogicConstraint,
54
- LiteralPattern,
55
- WildcardPattern,
56
- TuplePattern,
57
- Test,
58
- Assert,
59
- Truth
60
- } from "yukigo-ast"
61
-
62
- import { PrologLexer } from "./lexer.js"
63
-
64
- const asSequence = (d) => {
65
- if (d instanceof Sequence) return d;
66
- if (Array.isArray(d)) return d.length === 1 ? d[0] : new Sequence(d);
67
- return new Sequence([d]);
68
- };
69
-
70
-
71
- interface NearleyToken {
72
- value: any;
73
- [key: string]: any;
74
- };
75
-
76
- interface NearleyLexer {
77
- reset: (chunk: string, info: any) => void;
78
- next: () => NearleyToken | undefined;
79
- save: () => any;
80
- formatError: (token: never) => string;
81
- has: (tokenType: string) => boolean;
82
- };
83
-
84
- interface NearleyRule {
85
- name: string;
86
- symbols: NearleySymbol[];
87
- postprocess?: (d: any[], loc?: number, reject?: {}) => any;
88
- };
89
-
90
- type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };
91
-
92
- interface Grammar {
93
- Lexer: NearleyLexer | undefined;
94
- ParserRules: NearleyRule[];
95
- ParserStart: string;
96
- };
97
-
98
- const grammar: Grammar = {
99
- Lexer: PrologLexer,
100
- ParserRules: [
3
+ (function () {
4
+ function id(x) { return x[0]; }
5
+
6
+ const {
7
+ NumberPrimitive,
8
+ BooleanPrimitive,
9
+ StringPrimitive,
10
+ Rule,
11
+ Fact,
12
+ Query,
13
+ ListPrimitive,
14
+ ConsExpression,
15
+ ArithmeticBinaryOperation,
16
+ ArithmeticUnaryOperation,
17
+ ComparisonOperation,
18
+ Exist,
19
+ Not,
20
+ Findall,
21
+ Sequence,
22
+ UnguardedBody,
23
+ Equation,
24
+ If,
25
+ Call,
26
+ Forall,
27
+ SymbolPrimitive,
28
+ AssignOperation,
29
+ UnifyOperation,
30
+ VariablePattern,
31
+ FunctorPattern,
32
+ ConsPattern,
33
+ ListPattern,
34
+ LogicConstraint,
35
+ LiteralPattern,
36
+ WildcardPattern,
37
+ TuplePattern,
38
+ Test,
39
+ Assert,
40
+ Truth
41
+ } = require("yukigo-ast")
42
+
43
+ const { PrologLexer } = require("./lexer.js")
44
+
45
+ const asSequence = (d) => {
46
+ if (d instanceof Sequence) return d;
47
+ if (Array.isArray(d)) return d.length === 1 ? d[0] : new Sequence(d);
48
+ return new Sequence([d]);
49
+ };
50
+
51
+ var grammar = {
52
+ Lexer: PrologLexer,
53
+ ParserRules: [
101
54
  {"name": "program$ebnf$1", "symbols": []},
102
55
  {"name": "program$ebnf$1$subexpression$1", "symbols": ["clause", "_"]},
103
- {"name": "program$ebnf$1", "symbols": ["program$ebnf$1", "program$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
56
+ {"name": "program$ebnf$1", "symbols": ["program$ebnf$1", "program$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
104
57
  {"name": "program", "symbols": ["_", "program$ebnf$1"], "postprocess": (d) => d[1].map(x => x[0]).filter(x => x !== null).flat(Infinity)},
105
58
  {"name": "clause$subexpression$1", "symbols": ["fact"]},
106
59
  {"name": "clause$subexpression$1", "symbols": ["rule"]},
@@ -108,22 +61,24 @@ const grammar: Grammar = {
108
61
  {"name": "clause$subexpression$1", "symbols": ["test_rule"]},
109
62
  {"name": "clause", "symbols": ["clause$subexpression$1"], "postprocess": (d) => d[0][0]},
110
63
  {"name": "fact$ebnf$1", "symbols": ["arguments"], "postprocess": id},
111
- {"name": "fact$ebnf$1", "symbols": [], "postprocess": () => null},
64
+ {"name": "fact$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
112
65
  {"name": "fact", "symbols": ["any_atom", "fact$ebnf$1", "_", (PrologLexer.has("period") ? {type: "period"} : period)], "postprocess": (d) => new Fact(d[0], d[1] ?? [])},
113
66
  {"name": "rule", "symbols": ["any_atom", "equation", "_", (PrologLexer.has("period") ? {type: "period"} : period)], "postprocess": (d) => new Rule(d[0], [d[1]])},
114
67
  {"name": "test_rule$ebnf$1", "symbols": ["test_args"], "postprocess": id},
115
- {"name": "test_rule$ebnf$1", "symbols": [], "postprocess": () => null},
116
- {"name": "test_rule", "symbols": [(PrologLexer.has("testKeyword") ? {type: "testKeyword"} : testKeyword), (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "structural_literal", "test_rule$ebnf$1", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen), "equation", "_", (PrologLexer.has("period") ? {type: "period"} : period)], "postprocess": (d) => new Test(d[3], d[7].body.sequence, d[4] ? [d[4]] : [])},
68
+ {"name": "test_rule$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
69
+ {"name": "test_rule$subexpression$1", "symbols": [(PrologLexer.has("colonDash") ? {type: "colonDash"} : colonDash)]},
70
+ {"name": "test_rule$subexpression$1", "symbols": [(PrologLexer.has("colon") ? {type: "colon"} : colon)]},
71
+ {"name": "test_rule", "symbols": [(PrologLexer.has("testKeyword") ? {type: "testKeyword"} : testKeyword), (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "structural_literal", "test_rule$ebnf$1", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen), "_", "test_rule$subexpression$1", "_", "body", "_", (PrologLexer.has("period") ? {type: "period"} : period)], "postprocess": (d) => new Test(d[3], new Sequence(d[10]), d[4] ? [d[4]] : [])},
117
72
  {"name": "test_args", "symbols": ["_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "pattern"], "postprocess": (d) => d[3]},
118
73
  {"name": "equation$ebnf$1", "symbols": ["arguments"], "postprocess": id},
119
- {"name": "equation$ebnf$1", "symbols": [], "postprocess": () => null},
74
+ {"name": "equation$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
120
75
  {"name": "equation", "symbols": ["equation$ebnf$1", "_", (PrologLexer.has("colonDash") ? {type: "colonDash"} : colonDash), "_", "body"], "postprocess": (d) => new Equation(d[0] || [], new UnguardedBody(new Sequence(d[4])))},
121
76
  {"name": "query", "symbols": [(PrologLexer.has("queryOp") ? {type: "queryOp"} : queryOp), "_", "body", "_", (PrologLexer.has("period") ? {type: "period"} : period)], "postprocess": (d) => new Query(d[2])},
122
77
  {"name": "body$ebnf$1", "symbols": []},
123
78
  {"name": "body$ebnf$1$subexpression$1$subexpression$1", "symbols": [(PrologLexer.has("comma") ? {type: "comma"} : comma)]},
124
79
  {"name": "body$ebnf$1$subexpression$1$subexpression$1", "symbols": [(PrologLexer.has("semicolon") ? {type: "semicolon"} : semicolon)]},
125
80
  {"name": "body$ebnf$1$subexpression$1", "symbols": ["_", "body$ebnf$1$subexpression$1$subexpression$1", "_", "expression"]},
126
- {"name": "body$ebnf$1", "symbols": ["body$ebnf$1", "body$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
81
+ {"name": "body$ebnf$1", "symbols": ["body$ebnf$1", "body$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
127
82
  {"name": "body", "symbols": ["expression", "body$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])]},
128
83
  {"name": "expression$subexpression$1", "symbols": ["conditional"]},
129
84
  {"name": "expression$subexpression$1", "symbols": ["forall"]},
@@ -136,38 +91,38 @@ const grammar: Grammar = {
136
91
  {"name": "expression$subexpression$1", "symbols": ["assertion"]},
137
92
  {"name": "expression", "symbols": ["expression$subexpression$1"], "postprocess": (d) => d[0][0]},
138
93
  {"name": "expression", "symbols": [{"literal":"("}, "_", "body", "_", {"literal":")"}], "postprocess": (d) => new Sequence(d[2])},
139
- {"name": "conditional", "symbols": [{"literal":"("}, "_", "body", "_", {"literal":"->"}, "_", "body", "_", (PrologLexer.has("semicolon") ? {type: "semicolon"} : semicolon), "_", "body", "_", {"literal":")"}], "postprocess": (d) =>
140
- new If(
141
- asSequence(d[2]),
142
- asSequence(d[6]),
143
- asSequence(d[10])
144
- )
94
+ {"name": "conditional", "symbols": [{"literal":"("}, "_", "body", "_", {"literal":"->"}, "_", "body", "_", (PrologLexer.has("semicolon") ? {type: "semicolon"} : semicolon), "_", "body", "_", {"literal":")"}], "postprocess": (d) =>
95
+ new If(
96
+ asSequence(d[2]),
97
+ asSequence(d[6]),
98
+ asSequence(d[10])
99
+ )
145
100
  },
146
101
  {"name": "forall", "symbols": [(PrologLexer.has("forallRule") ? {type: "forallRule"} : forallRule), {"literal":"("}, "_", "expression", "_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "expression", "_", {"literal":")"}], "postprocess": (d) => new Forall(d[3], d[7])},
147
102
  {"name": "findall", "symbols": [(PrologLexer.has("findallRule") ? {type: "findallRule"} : findallRule), {"literal":"("}, "_", "pattern", "_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "expression", "_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "pattern", "_", {"literal":")"}], "postprocess": (d) => new Findall(d[3], d[7], d[11])},
148
103
  {"name": "not", "symbols": [{"literal":"not"}, {"literal":"("}, "_", "expression", "_", {"literal":")"}], "postprocess": (d) => new Not(asSequence(d[3]))},
149
104
  {"name": "not", "symbols": [{"literal":"\\+"}, "_", "expression"], "postprocess": (d) => new Not(d[2])},
150
- {"name": "exist", "symbols": [{"literal":"call"}, (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "pattern_list", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) => {
151
- const [callee, ...rest] = d[3]
152
- return new Call(callee.name, rest)
105
+ {"name": "exist", "symbols": [{"literal":"call"}, (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "pattern_list", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) => {
106
+ const [callee, ...rest] = d[3]
107
+ return new Call(callee.name, rest)
153
108
  } },
154
109
  {"name": "exist$ebnf$1", "symbols": ["arguments"], "postprocess": id},
155
- {"name": "exist$ebnf$1", "symbols": [], "postprocess": () => null},
156
- {"name": "exist", "symbols": ["any_atom", "exist$ebnf$1"], "postprocess": (d, l, reject) => {
157
- const val = d[0].value;
158
- if (["not", "\\+", "call", "assertion"].includes(val)) return reject;
159
- return new Exist(d[0], d[1] ?? [])
110
+ {"name": "exist$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
111
+ {"name": "exist", "symbols": ["any_atom", "exist$ebnf$1"], "postprocess": (d, l, reject) => {
112
+ const val = d[0].value;
113
+ if (["not", "\\+", "call", "assertion"].includes(val)) return reject;
114
+ return new Exist(d[0], d[1] ?? [])
160
115
  } },
161
116
  {"name": "exist", "symbols": ["variable"], "postprocess": (d) => new Exist(d[0], [])},
162
- {"name": "assertion", "symbols": [{"literal":"assertion"}, (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "expression", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) =>
163
- new Assert(null, new Truth(asSequence(d[3])))
117
+ {"name": "assertion", "symbols": [{"literal":"assertion"}, (PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "expression", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) =>
118
+ new Assert(new BooleanPrimitive(false), new Truth(asSequence(d[3])))
164
119
  },
165
- {"name": "assignment", "symbols": ["addition", "_", {"literal":"is"}, "_", "addition"], "postprocess": (d) =>
166
- new LogicConstraint(new AssignOperation("Assign", d[0], d[4]))
120
+ {"name": "assignment", "symbols": ["addition", "_", {"literal":"is"}, "_", "addition"], "postprocess": (d) =>
121
+ new LogicConstraint(new AssignOperation("Assign", d[0], d[4]))
167
122
  },
168
123
  {"name": "unification", "symbols": ["addition", "_", {"literal":"="}, "_", "addition"], "postprocess": (d) => new LogicConstraint(new UnifyOperation("Unify", d[0], d[4]))},
169
- {"name": "comparison", "symbols": ["addition", "_", "comparison_op", "_", "addition"], "postprocess": (d) =>
170
- new LogicConstraint(new ComparisonOperation(d[2], d[0], d[4]))
124
+ {"name": "comparison", "symbols": ["addition", "_", "comparison_op", "_", "addition"], "postprocess": (d) =>
125
+ new LogicConstraint(new ComparisonOperation(d[2], d[0], d[4]))
171
126
  },
172
127
  {"name": "addition", "symbols": ["multiplication", "_", {"literal":"+"}, "_", "addition"], "postprocess": (d) => new ArithmeticBinaryOperation("Plus", d[0], d[4])},
173
128
  {"name": "addition", "symbols": ["multiplication", "_", {"literal":"-"}, "_", "addition"], "postprocess": (d) => new ArithmeticBinaryOperation("Minus", d[0], d[4])},
@@ -178,26 +133,26 @@ const grammar: Grammar = {
178
133
  {"name": "primary", "symbols": ["arithmetic_literal"], "postprocess": id},
179
134
  {"name": "primary", "symbols": ["variable"], "postprocess": id},
180
135
  {"name": "primary", "symbols": [{"literal":"-"}, "_", "primary"], "postprocess": (d) => new ArithmeticUnaryOperation("Negation", d[2])},
181
- {"name": "primary", "symbols": ["strict_atom", "arguments"], "postprocess": (d, l, reject) => {
182
- const val = d[0].value;
183
- if (["abs", "round", "sqrt", "max", "assertion"].includes(val)) return reject;
184
- return new Exist(d[0], d[1] ?? [])
136
+ {"name": "primary", "symbols": ["strict_atom", "arguments"], "postprocess": (d, l, reject) => {
137
+ const val = d[0].value;
138
+ if (["abs", "round", "sqrt", "max", "assertion"].includes(val)) return reject;
139
+ return new Exist(d[0], d[1] ?? [])
185
140
  } },
186
141
  {"name": "primary", "symbols": ["primitiveOperation"], "postprocess": id},
187
142
  {"name": "primary", "symbols": ["cons_expr"], "postprocess": id},
188
143
  {"name": "primary", "symbols": ["list_expr"], "postprocess": id},
189
144
  {"name": "primary", "symbols": [{"literal":"("}, "_", "addition", "_", {"literal":")"}], "postprocess": d => d[2]},
190
145
  {"name": "list_expr$ebnf$1", "symbols": ["primary_list"], "postprocess": id},
191
- {"name": "list_expr$ebnf$1", "symbols": [], "postprocess": () => null},
146
+ {"name": "list_expr$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
192
147
  {"name": "list_expr", "symbols": [{"literal":"["}, "_", "list_expr$ebnf$1", "_", {"literal":"]"}], "postprocess": (d) => new ListPrimitive(d[2] || [])},
193
- {"name": "cons_expr", "symbols": [{"literal":"["}, "_", "primary_list", "_", (PrologLexer.has("consOp") ? {type: "consOp"} : consOp), "_", "addition", "_", {"literal":"]"}], "postprocess": (d) => {
194
- const heads = d[2];
195
- const tail = d[6];
196
- let current = tail;
197
- for (let i = heads.length - 1; i >= 0; i--) {
198
- current = new ConsExpression(heads[i], current);
199
- }
200
- return current;
148
+ {"name": "cons_expr", "symbols": [{"literal":"["}, "_", "primary_list", "_", (PrologLexer.has("consOp") ? {type: "consOp"} : consOp), "_", "addition", "_", {"literal":"]"}], "postprocess": (d) => {
149
+ const heads = d[2];
150
+ const tail = d[6];
151
+ let current = tail;
152
+ for (let i = heads.length - 1; i >= 0; i--) {
153
+ current = new ConsExpression(heads[i], current);
154
+ }
155
+ return current;
201
156
  } },
202
157
  {"name": "primitiveOperation", "symbols": [{"literal":"round"}, "__", "addition"], "postprocess": d => new ArithmeticUnaryOperation("Round", d[2])},
203
158
  {"name": "primitiveOperation", "symbols": [{"literal":"abs"}, "__", "addition"], "postprocess": d => new ArithmeticUnaryOperation("Absolute", d[2])},
@@ -206,12 +161,12 @@ const grammar: Grammar = {
206
161
  {"name": "primitiveArguments", "symbols": [(PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "primary_list", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) => d[2]},
207
162
  {"name": "primary_list$ebnf$1", "symbols": []},
208
163
  {"name": "primary_list$ebnf$1$subexpression$1", "symbols": ["_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "addition"]},
209
- {"name": "primary_list$ebnf$1", "symbols": ["primary_list$ebnf$1", "primary_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
164
+ {"name": "primary_list$ebnf$1", "symbols": ["primary_list$ebnf$1", "primary_list$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
210
165
  {"name": "primary_list", "symbols": ["addition", "primary_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])]},
211
166
  {"name": "arguments", "symbols": [(PrologLexer.has("lparen") ? {type: "lparen"} : lparen), "_", "pattern_list", "_", (PrologLexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": (d) => d[2]},
212
167
  {"name": "pattern_list$ebnf$1", "symbols": []},
213
168
  {"name": "pattern_list$ebnf$1$subexpression$1", "symbols": ["_", (PrologLexer.has("comma") ? {type: "comma"} : comma), "_", "pattern"]},
214
- {"name": "pattern_list$ebnf$1", "symbols": ["pattern_list$ebnf$1", "pattern_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
169
+ {"name": "pattern_list$ebnf$1", "symbols": ["pattern_list$ebnf$1", "pattern_list$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
215
170
  {"name": "pattern_list", "symbols": ["pattern", "pattern_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])]},
216
171
  {"name": "pattern", "symbols": ["infix_pattern"], "postprocess": id},
217
172
  {"name": "pattern", "symbols": ["primary_pattern"], "postprocess": id},
@@ -220,17 +175,17 @@ const grammar: Grammar = {
220
175
  {"name": "primary_pattern", "symbols": [(PrologLexer.has("wildcard") ? {type: "wildcard"} : wildcard)], "postprocess": (d) => new WildcardPattern()},
221
176
  {"name": "primary_pattern", "symbols": ["any_atom", "arguments"], "postprocess": (d) => new FunctorPattern(d[0], d[1])},
222
177
  {"name": "primary_pattern", "symbols": [{"literal":"("}, "_", "pattern_list", "_", {"literal":")"}], "postprocess": (d) => new TuplePattern(d[2])},
223
- {"name": "primary_pattern", "symbols": [{"literal":"["}, "_", "pattern_list", "_", (PrologLexer.has("consOp") ? {type: "consOp"} : consOp), "_", "pattern", "_", {"literal":"]"}], "postprocess": (d) => {
224
- const heads = d[2];
225
- const tail = d[6];
226
- let current = tail;
227
- for (let i = heads.length - 1; i >= 0; i--) {
228
- current = new ConsPattern(heads[i], current);
229
- }
230
- return current;
178
+ {"name": "primary_pattern", "symbols": [{"literal":"["}, "_", "pattern_list", "_", (PrologLexer.has("consOp") ? {type: "consOp"} : consOp), "_", "pattern", "_", {"literal":"]"}], "postprocess": (d) => {
179
+ const heads = d[2];
180
+ const tail = d[6];
181
+ let current = tail;
182
+ for (let i = heads.length - 1; i >= 0; i--) {
183
+ current = new ConsPattern(heads[i], current);
184
+ }
185
+ return current;
231
186
  } },
232
187
  {"name": "primary_pattern$ebnf$1", "symbols": ["pattern_list"], "postprocess": id},
233
- {"name": "primary_pattern$ebnf$1", "symbols": [], "postprocess": () => null},
188
+ {"name": "primary_pattern$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
234
189
  {"name": "primary_pattern", "symbols": [{"literal":"["}, "_", "primary_pattern$ebnf$1", "_", {"literal":"]"}], "postprocess": (d) => new ListPattern(d[2] ? d[2] : [])},
235
190
  {"name": "infix_pattern", "symbols": ["primary_pattern", "_", "any_atom", "_", "pattern"], "postprocess": (d) => new FunctorPattern(d[2], [d[0], d[4]])},
236
191
  {"name": "variable", "symbols": [(PrologLexer.has("variable") ? {type: "variable"} : variable)], "postprocess": (d) => new SymbolPrimitive(d[0].value)},
@@ -262,13 +217,17 @@ const grammar: Grammar = {
262
217
  {"name": "comparison_op", "symbols": [{"literal":"=@="}], "postprocess": d => "Same"},
263
218
  {"name": "comparison_op", "symbols": [{"literal":"\\=@="}], "postprocess": d => "NotSame"},
264
219
  {"name": "_$ebnf$1", "symbols": []},
265
- {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", (PrologLexer.has("WS") ? {type: "WS"} : WS)], "postprocess": (d) => d[0].concat([d[1]])},
220
+ {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", (PrologLexer.has("WS") ? {type: "WS"} : WS)], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
266
221
  {"name": "_", "symbols": ["_$ebnf$1"]},
267
222
  {"name": "__$ebnf$1", "symbols": [(PrologLexer.has("WS") ? {type: "WS"} : WS)], "postprocess": id},
268
- {"name": "__$ebnf$1", "symbols": [], "postprocess": () => null},
223
+ {"name": "__$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
269
224
  {"name": "__", "symbols": ["__$ebnf$1"]}
270
- ],
271
- ParserStart: "program",
272
- };
273
-
274
- export default grammar;
225
+ ]
226
+ , ParserStart: "program"
227
+ }
228
+ if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
229
+ module.exports = grammar;
230
+ } else {
231
+ window.grammar = grammar;
232
+ }
233
+ })();
@@ -0,0 +1,3 @@
1
+ import { CompiledRules } from "nearley";
2
+ declare const grammar: CompiledRules;
3
+ export = grammar;