yukigo-haskell-parser 0.1.0 → 0.1.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.
Files changed (65) hide show
  1. package/.mocharc.json +3 -3
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +10 -10
  4. package/dist/index.d.ts +13 -2
  5. package/dist/index.js +112 -32
  6. package/dist/index.js.map +1 -1
  7. package/dist/parser/grammar.js +220 -231
  8. package/dist/parser/grammar.js.map +1 -1
  9. package/dist/parser/lexer.d.ts +70 -15
  10. package/dist/parser/lexer.js +259 -50
  11. package/dist/parser/lexer.js.map +1 -1
  12. package/dist/prelude.d.ts +1 -1
  13. package/dist/prelude.js +280 -204
  14. package/dist/prelude.js.map +1 -1
  15. package/dist/typechecker/DeclarationCollector.d.ts +6 -1
  16. package/dist/typechecker/DeclarationCollector.js +39 -0
  17. package/dist/typechecker/DeclarationCollector.js.map +1 -1
  18. package/dist/typechecker/TypeBuilder.d.ts +1 -1
  19. package/dist/typechecker/TypeBuilder.js +6 -2
  20. package/dist/typechecker/TypeBuilder.js.map +1 -1
  21. package/dist/typechecker/checker.d.ts +15 -4
  22. package/dist/typechecker/checker.js +108 -25
  23. package/dist/typechecker/checker.js.map +1 -1
  24. package/dist/typechecker/core.d.ts +4 -0
  25. package/dist/typechecker/core.js +45 -19
  26. package/dist/typechecker/core.js.map +1 -1
  27. package/dist/typechecker/inference.d.ts +5 -1
  28. package/dist/typechecker/inference.js +95 -21
  29. package/dist/typechecker/inference.js.map +1 -1
  30. package/dist/utils/helpers.d.ts +1 -1
  31. package/dist/utils/helpers.js +1 -1
  32. package/dist/utils/helpers.js.map +1 -1
  33. package/dist/utils/types.d.ts +1 -1
  34. package/dist/utils/types.js +7 -0
  35. package/dist/utils/types.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/index.ts +192 -55
  38. package/src/parser/grammar.ne +519 -463
  39. package/src/parser/grammar.ts +230 -239
  40. package/src/parser/lexer.ts +353 -77
  41. package/src/prelude.ts +282 -206
  42. package/src/typechecker/DeclarationCollector.ts +157 -104
  43. package/src/typechecker/TypeBuilder.ts +150 -148
  44. package/src/typechecker/checker.ts +501 -395
  45. package/src/typechecker/core.ts +192 -162
  46. package/src/typechecker/inference.ts +1421 -1327
  47. package/src/utils/helpers.ts +29 -29
  48. package/src/utils/types.ts +63 -56
  49. package/tests/hspec.spec.ts +92 -0
  50. package/tests/lexer.spec.ts +175 -0
  51. package/tests/parser.spec.ts +829 -823
  52. package/tests/prelude.spec.ts +17 -22
  53. package/tests/typechecker.spec.ts +327 -310
  54. package/tsconfig.json +26 -17
  55. package/tsconfig.tsbuildinfo +1 -0
  56. package/dist/parser/layoutPreprocessor.d.ts +0 -1
  57. package/dist/parser/layoutPreprocessor.js +0 -22
  58. package/dist/parser/layoutPreprocessor.js.map +0 -1
  59. package/dist/parser/preprocessor.d.ts +0 -28
  60. package/dist/parser/preprocessor.js +0 -453
  61. package/dist/parser/preprocessor.js.map +0 -1
  62. package/src/parser/layoutPreprocessor.ts +0 -21
  63. package/src/parser/preprocessor.ne +0 -375
  64. package/src/parser/preprocessor.ts +0 -502
  65. package/tests/preprocessor.spec.ts +0 -69
@@ -1,502 +0,0 @@
1
- // Generated automatically by nearley, version 2.20.1
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 comment: any;
7
- declare var NL: any;
8
- declare var lbracket: any;
9
- declare var rbracket: any;
10
- declare var typeClass: any;
11
- declare var typeEquals: any;
12
- declare var op: any;
13
- declare var assign: any;
14
- declare var anonymousVariable: any;
15
- declare var arrow: any;
16
- declare var typeArrow: any;
17
- declare var constructor: any;
18
- declare var variable: any;
19
- declare var number: any;
20
- declare var char: any;
21
- declare var string: any;
22
- declare var bool: any;
23
- declare var WS: any;
24
-
25
- import { HSLexer } from "./lexer.js"
26
-
27
- const filter = d => {
28
- return d.filter((token) => token !== null);
29
- };
30
-
31
-
32
- interface NearleyToken {
33
- value: any;
34
- [key: string]: any;
35
- };
36
-
37
- interface NearleyLexer {
38
- reset: (chunk: string, info: any) => void;
39
- next: () => NearleyToken | undefined;
40
- save: () => any;
41
- formatError: (token: never) => string;
42
- has: (tokenType: string) => boolean;
43
- };
44
-
45
- interface NearleyRule {
46
- name: string;
47
- symbols: NearleySymbol[];
48
- postprocess?: (d: any[], loc?: number, reject?: {}) => any;
49
- };
50
-
51
- type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };
52
-
53
- interface Grammar {
54
- Lexer: NearleyLexer | undefined;
55
- ParserRules: NearleyRule[];
56
- ParserStart: string;
57
- };
58
-
59
- const grammar: Grammar = {
60
- Lexer: HSLexer,
61
- ParserRules: [
62
- {"name": "program$ebnf$1", "symbols": []},
63
- {"name": "program$ebnf$1", "symbols": ["program$ebnf$1", "declaration"], "postprocess": (d) => d[0].concat([d[1]])},
64
- {"name": "program", "symbols": ["program$ebnf$1"], "postprocess": (d) => d[0].filter(x => x !== null).join("\n")},
65
- {"name": "program", "symbols": ["apply_operator"], "postprocess": id},
66
- {"name": "declaration$subexpression$1", "symbols": ["function_declaration"]},
67
- {"name": "declaration$subexpression$1", "symbols": ["function_signature"]},
68
- {"name": "declaration$subexpression$1", "symbols": ["type_declaration"]},
69
- {"name": "declaration$subexpression$1", "symbols": ["data_declaration"]},
70
- {"name": "declaration$subexpression$1", "symbols": ["comment"]},
71
- {"name": "declaration$subexpression$1", "symbols": ["empty_line"]},
72
- {"name": "declaration", "symbols": ["declaration$subexpression$1"], "postprocess": (d) => d[0][0]},
73
- {"name": "comment", "symbols": [(HSLexer.has("comment") ? {type: "comment"} : comment)], "postprocess": d => null},
74
- {"name": "empty_line", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL)], "postprocess": d => null},
75
- {"name": "expression$subexpression$1", "symbols": ["type_cast"]},
76
- {"name": "expression$subexpression$1", "symbols": ["letin_expression"]},
77
- {"name": "expression$subexpression$1", "symbols": ["if_expression"]},
78
- {"name": "expression$subexpression$1", "symbols": ["case_expression"]},
79
- {"name": "expression", "symbols": ["expression$subexpression$1"], "postprocess": (d) => `${d[0][0]}`},
80
- {"name": "type_cast", "symbols": ["apply_operator", "_", {"literal":"::"}, "_", "type"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
81
- {"name": "type_cast", "symbols": ["apply_operator"], "postprocess": (d) => d[0]},
82
- {"name": "apply_operator", "symbols": ["logical_expression", "_", {"literal":"$"}, "_", "apply_operator"], "postprocess": (d) => `${d[0]} $ ${d[4]}`},
83
- {"name": "apply_operator", "symbols": ["logical_expression"], "postprocess": (d) => d[0]},
84
- {"name": "logical_expression", "symbols": ["comparison", "_", {"literal":"&&"}, "_", "logical_expression"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
85
- {"name": "logical_expression", "symbols": ["comparison", "_", {"literal":"||"}, "_", "logical_expression"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
86
- {"name": "logical_expression", "symbols": ["comparison"], "postprocess": (d) => d[0]},
87
- {"name": "comparison", "symbols": ["cons_expression", "_", "comparison_operator", "_", "cons_expression"], "postprocess": (d) => `${d[0]} ${d[2]} ${d[4]}`},
88
- {"name": "comparison", "symbols": ["cons_expression"], "postprocess": (d) => d[0]},
89
- {"name": "cons_expression", "symbols": ["concatenation", "_", {"literal":":"}, "_", "cons_expression"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
90
- {"name": "cons_expression", "symbols": ["concatenation"], "postprocess": (d) => d[0]},
91
- {"name": "concatenation", "symbols": ["addition", "_", {"literal":"++"}, "_", "concatenation"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
92
- {"name": "concatenation", "symbols": ["addition"], "postprocess": (d) => d[0]},
93
- {"name": "addition", "symbols": ["addition", "_", {"literal":"+"}, "_", "multiplication"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
94
- {"name": "addition", "symbols": ["addition", "_", {"literal":"-"}, "_", "multiplication"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
95
- {"name": "addition", "symbols": ["multiplication"], "postprocess": (d) => d[0]},
96
- {"name": "multiplication", "symbols": ["multiplication", "_", {"literal":"*"}, "_", "power"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
97
- {"name": "multiplication", "symbols": ["multiplication", "_", {"literal":"/"}, "_", "power"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
98
- {"name": "multiplication", "symbols": ["power"], "postprocess": (d) => d[0]},
99
- {"name": "power", "symbols": ["unary_negation", "_", {"literal":"**"}, "_", "power"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
100
- {"name": "power", "symbols": ["unary_negation", "_", {"literal":"^"}, "_", "power"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
101
- {"name": "power", "symbols": ["unary_negation", "_", {"literal":"^^"}, "_", "power"], "postprocess": (d) => `${d[0]} ${d[2].value} ${d[4]}`},
102
- {"name": "power", "symbols": ["unary_negation"], "postprocess": (d) => d[0]},
103
- {"name": "unary_negation", "symbols": [{"literal":"-"}, "_", "unary_negation"], "postprocess": (d) => `-${d[2]}`},
104
- {"name": "unary_negation", "symbols": ["index_access"], "postprocess": (d) => d[0]},
105
- {"name": "index_access", "symbols": ["index_access", "_", {"literal":"!!"}, "_", "composition_expression"], "postprocess": (d) => `${d[0]} !! ${d[4]}`},
106
- {"name": "index_access", "symbols": ["composition_expression"], "postprocess": d => d[0]},
107
- {"name": "composition_expression", "symbols": ["composition_expression", "_", {"literal":"."}, "_", "infix_operator_expression"], "postprocess": (d) => `${d[0]} . ${d[4]}`},
108
- {"name": "composition_expression", "symbols": ["infix_operator_expression"], "postprocess": d => d[0]},
109
- {"name": "infix_operator_expression", "symbols": ["infix_operator_expression", "_", {"literal":"`"}, "_", "variable", "_", {"literal":"`"}, "_", "application"], "postprocess": (d) => `${d[0]} \`${d[4]}\` ${d[8]}`},
110
- {"name": "infix_operator_expression", "symbols": ["application"], "postprocess": d => d[0]},
111
- {"name": "application", "symbols": [{"literal":"error"}, "__", "primary"], "postprocess": d => `error ${d[2]}`},
112
- {"name": "application$ebnf$1", "symbols": []},
113
- {"name": "application$ebnf$1$subexpression$1$subexpression$1", "symbols": ["__"]},
114
- {"name": "application$ebnf$1$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
115
- {"name": "application$ebnf$1$subexpression$1", "symbols": ["application$ebnf$1$subexpression$1$subexpression$1", "primary"]},
116
- {"name": "application$ebnf$1", "symbols": ["application$ebnf$1", "application$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
117
- {"name": "application", "symbols": ["primary", "application$ebnf$1"], "postprocess": (d) => {
118
- if (d[1].length === 0) return d[0];
119
- return [d[0], ...d[1].map(x => x[1])].join(" ");
120
- } },
121
- {"name": "operator$subexpression$1", "symbols": [{"literal":"=="}]},
122
- {"name": "operator$subexpression$1", "symbols": [{"literal":"/="}]},
123
- {"name": "operator$subexpression$1", "symbols": [{"literal":"<"}]},
124
- {"name": "operator$subexpression$1", "symbols": [{"literal":">"}]},
125
- {"name": "operator$subexpression$1", "symbols": [{"literal":"<="}]},
126
- {"name": "operator$subexpression$1", "symbols": [{"literal":">="}]},
127
- {"name": "operator$subexpression$1", "symbols": [{"literal":"++"}]},
128
- {"name": "operator$subexpression$1", "symbols": [{"literal":"+"}]},
129
- {"name": "operator$subexpression$1", "symbols": [{"literal":","}]},
130
- {"name": "operator$subexpression$1", "symbols": [{"literal":"*"}]},
131
- {"name": "operator$subexpression$1", "symbols": [{"literal":"/"}]},
132
- {"name": "operator$subexpression$1", "symbols": [{"literal":":"}]},
133
- {"name": "operator", "symbols": ["operator$subexpression$1"], "postprocess": (d) => d[0][0].value},
134
- {"name": "left_section", "symbols": [{"literal":"("}, "_", "expression", "_", "operator", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]} ${d[4]})`},
135
- {"name": "right_section", "symbols": [{"literal":"("}, "_", "operator", "_", "expression", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]} ${d[4]})`},
136
- {"name": "operator_section", "symbols": [{"literal":"("}, "_", "operator", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
137
- {"name": "primary", "symbols": ["primitive"], "postprocess": (d) => d[0]},
138
- {"name": "primary", "symbols": ["variable"], "postprocess": (d) => d[0]},
139
- {"name": "primary", "symbols": ["constr"], "postprocess": (d) => d[0]},
140
- {"name": "primary", "symbols": ["tuple_expression"], "postprocess": (d) => d[0]},
141
- {"name": "primary", "symbols": ["left_section"], "postprocess": (d) => d[0]},
142
- {"name": "primary", "symbols": ["right_section"], "postprocess": (d) => d[0]},
143
- {"name": "primary", "symbols": ["operator_section"], "postprocess": (d) => d[0]},
144
- {"name": "primary", "symbols": [{"literal":"("}, "_", "expression", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
145
- {"name": "primary", "symbols": [{"literal":"["}, "_", "range_expression", "_", {"literal":"]"}], "postprocess": (d) => `[${d[2]}]`},
146
- {"name": "primary", "symbols": ["list_literal"], "postprocess": (d) => d[0]},
147
- {"name": "primary", "symbols": ["lambda_expression"], "postprocess": (d) => d[0]},
148
- {"name": "primary", "symbols": ["data_expression"], "postprocess": d => d[0]},
149
- {"name": "primary", "symbols": ["list_comprehension"], "postprocess": (d) => d[0]},
150
- {"name": "list_comprehension", "symbols": [{"literal":"["}, "_", "expression", "_", {"literal":"|"}, "_", "comprehension_clause_list", "_", {"literal":"]"}], "postprocess": (d) => `[${d[2]} | ${d[6]}]`},
151
- {"name": "comprehension_clause_list$ebnf$1", "symbols": []},
152
- {"name": "comprehension_clause_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "comprehension_clause"]},
153
- {"name": "comprehension_clause_list$ebnf$1", "symbols": ["comprehension_clause_list$ebnf$1", "comprehension_clause_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
154
- {"name": "comprehension_clause_list", "symbols": ["comprehension_clause", "comprehension_clause_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map((x) => x[3])].join(`, `)},
155
- {"name": "comprehension_clause", "symbols": ["variable", "_", {"literal":"<-"}, "_", "expression"], "postprocess": (d) => `${d[0]} <- ${d[4]}`},
156
- {"name": "comprehension_clause", "symbols": ["expression"], "postprocess": (d) => d[0]},
157
- {"name": "lambda_expression$subexpression$1", "symbols": ["_"]},
158
- {"name": "lambda_expression$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
159
- {"name": "lambda_expression$subexpression$2", "symbols": ["_"]},
160
- {"name": "lambda_expression$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
161
- {"name": "lambda_expression", "symbols": [{"literal":"("}, "_", {"literal":"\\"}, "_", "parameter_list", "_", {"literal":"->"}, "lambda_expression$subexpression$1", "expression", "lambda_expression$subexpression$2", {"literal":")"}], "postprocess": (d) => `(\\${d[4]} -> ${d[8]})`},
162
- {"name": "tuple_expression$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "tuple_value"]},
163
- {"name": "tuple_expression$ebnf$1", "symbols": ["tuple_expression$ebnf$1$subexpression$1"]},
164
- {"name": "tuple_expression$ebnf$1$subexpression$2", "symbols": ["_", {"literal":","}, "_", "tuple_value"]},
165
- {"name": "tuple_expression$ebnf$1", "symbols": ["tuple_expression$ebnf$1", "tuple_expression$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
166
- {"name": "tuple_expression", "symbols": [{"literal":"("}, "_", "tuple_value", "tuple_expression$ebnf$1", "_", {"literal":")"}], "postprocess": (d) => `(` + [d[2], ...d[3].map(x => `,${x[3]}`)].join(``) + `)`},
167
- {"name": "tuple_value", "symbols": ["expression"], "postprocess": d => d[0]},
168
- {"name": "data_expression", "symbols": ["constr", "_", (HSLexer.has("lbracket") ? {type: "lbracket"} : lbracket), "_", "fields_expressions", "_", (HSLexer.has("rbracket") ? {type: "rbracket"} : rbracket)], "postprocess":
169
- (d) => d[0] + ` { ` + d[4] + ` }`
170
- },
171
- {"name": "fields_expressions$ebnf$1", "symbols": []},
172
- {"name": "fields_expressions$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "field_exp"]},
173
- {"name": "fields_expressions$ebnf$1", "symbols": ["fields_expressions$ebnf$1", "fields_expressions$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
174
- {"name": "fields_expressions", "symbols": ["field_exp", "fields_expressions$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])].join(", ")},
175
- {"name": "field_exp", "symbols": ["variable", "_", {"literal":"="}, "_", "expression"], "postprocess": (d) => d[0] + ` = ` + d[4]},
176
- {"name": "if_expression$subexpression$1", "symbols": ["__"]},
177
- {"name": "if_expression$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
178
- {"name": "if_expression$subexpression$1", "symbols": ["if_expression$subexpression$1$subexpression$1"]},
179
- {"name": "if_expression$subexpression$2", "symbols": ["__"]},
180
- {"name": "if_expression$subexpression$2$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
181
- {"name": "if_expression$subexpression$2", "symbols": ["if_expression$subexpression$2$subexpression$1"]},
182
- {"name": "if_expression$subexpression$3", "symbols": ["__"]},
183
- {"name": "if_expression$subexpression$3$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
184
- {"name": "if_expression$subexpression$3", "symbols": ["if_expression$subexpression$3$subexpression$1"]},
185
- {"name": "if_expression$subexpression$4", "symbols": ["__"]},
186
- {"name": "if_expression$subexpression$4$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
187
- {"name": "if_expression$subexpression$4", "symbols": ["if_expression$subexpression$4$subexpression$1"]},
188
- {"name": "if_expression$subexpression$5", "symbols": ["__"]},
189
- {"name": "if_expression$subexpression$5$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
190
- {"name": "if_expression$subexpression$5", "symbols": ["if_expression$subexpression$5$subexpression$1"]},
191
- {"name": "if_expression", "symbols": [{"literal":"if"}, "if_expression$subexpression$1", "expression", "if_expression$subexpression$2", {"literal":"then"}, "if_expression$subexpression$3", "expression", "if_expression$subexpression$4", {"literal":"else"}, "if_expression$subexpression$5", "expression"], "postprocess":
192
- (d) => `if ` + d[2] + ` then ` + d[6] + ` else ` + d[10]
193
- },
194
- {"name": "letin_expression$subexpression$1", "symbols": ["_"]},
195
- {"name": "letin_expression$subexpression$1$subexpression$1", "symbols": ["_", {"literal":"{"}, "_"]},
196
- {"name": "letin_expression$subexpression$1", "symbols": ["letin_expression$subexpression$1$subexpression$1"]},
197
- {"name": "letin_expression$subexpression$1$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
198
- {"name": "letin_expression$subexpression$1", "symbols": ["letin_expression$subexpression$1$subexpression$2"]},
199
- {"name": "letin_expression$ebnf$1", "symbols": ["bindings_list"], "postprocess": id},
200
- {"name": "letin_expression$ebnf$1", "symbols": [], "postprocess": () => null},
201
- {"name": "letin_expression$subexpression$2", "symbols": ["_"]},
202
- {"name": "letin_expression$subexpression$2$subexpression$1", "symbols": ["_", {"literal":"}"}, "_"]},
203
- {"name": "letin_expression$subexpression$2", "symbols": ["letin_expression$subexpression$2$subexpression$1"]},
204
- {"name": "letin_expression$subexpression$2$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
205
- {"name": "letin_expression$subexpression$2", "symbols": ["letin_expression$subexpression$2$subexpression$2"]},
206
- {"name": "letin_expression$subexpression$3$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
207
- {"name": "letin_expression$subexpression$3", "symbols": ["letin_expression$subexpression$3$subexpression$1"]},
208
- {"name": "letin_expression$subexpression$3", "symbols": ["_"]},
209
- {"name": "letin_expression", "symbols": [{"literal":"let"}, "letin_expression$subexpression$1", "letin_expression$ebnf$1", "letin_expression$subexpression$2", {"literal":"in"}, "letin_expression$subexpression$3", "expression"], "postprocess": (d) => `let { ${(d[2] ?? ``)} }` + ` in ` + d[6]},
210
- {"name": "case_expression$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
211
- {"name": "case_expression$subexpression$1", "symbols": ["case_expression$subexpression$1$subexpression$1"]},
212
- {"name": "case_expression$subexpression$1", "symbols": ["_"]},
213
- {"name": "case_expression$subexpression$2$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
214
- {"name": "case_expression$subexpression$2", "symbols": ["case_expression$subexpression$2$subexpression$1"]},
215
- {"name": "case_expression$subexpression$2", "symbols": ["_"]},
216
- {"name": "case_expression$subexpression$3", "symbols": ["_"]},
217
- {"name": "case_expression$subexpression$3$subexpression$1", "symbols": ["_", {"literal":"{"}, "_"]},
218
- {"name": "case_expression$subexpression$3", "symbols": ["case_expression$subexpression$3$subexpression$1"]},
219
- {"name": "case_expression$subexpression$3$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
220
- {"name": "case_expression$subexpression$3", "symbols": ["case_expression$subexpression$3$subexpression$2"]},
221
- {"name": "case_expression$ebnf$1$subexpression$1", "symbols": ["_", {"literal":"}"}, "_"]},
222
- {"name": "case_expression$ebnf$1", "symbols": ["case_expression$ebnf$1$subexpression$1"], "postprocess": id},
223
- {"name": "case_expression$ebnf$1", "symbols": [], "postprocess": () => null},
224
- {"name": "case_expression", "symbols": [{"literal":"case"}, "case_expression$subexpression$1", "expression", "case_expression$subexpression$2", {"literal":"of"}, "case_expression$subexpression$3", "case_arms", "case_expression$ebnf$1"], "postprocess": (d) => `case ${d[2]} of { ${d[6]} }`},
225
- {"name": "case_arms$ebnf$1", "symbols": []},
226
- {"name": "case_arms$ebnf$1$subexpression$1$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
227
- {"name": "case_arms$ebnf$1$subexpression$1$subexpression$1", "symbols": ["case_arms$ebnf$1$subexpression$1$subexpression$1$subexpression$1"]},
228
- {"name": "case_arms$ebnf$1$subexpression$1$subexpression$1$subexpression$2", "symbols": ["_", {"literal":";"}, "_"]},
229
- {"name": "case_arms$ebnf$1$subexpression$1$subexpression$1", "symbols": ["case_arms$ebnf$1$subexpression$1$subexpression$1$subexpression$2"]},
230
- {"name": "case_arms$ebnf$1$subexpression$1", "symbols": ["case_arms$ebnf$1$subexpression$1$subexpression$1", "case_arm"]},
231
- {"name": "case_arms$ebnf$1", "symbols": ["case_arms$ebnf$1", "case_arms$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
232
- {"name": "case_arms", "symbols": ["case_arm", "case_arms$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[1])].join("; ")},
233
- {"name": "case_arm$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
234
- {"name": "case_arm$subexpression$1", "symbols": ["case_arm$subexpression$1$subexpression$1"]},
235
- {"name": "case_arm$subexpression$1", "symbols": ["_"]},
236
- {"name": "case_arm$subexpression$2$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
237
- {"name": "case_arm$subexpression$2", "symbols": ["case_arm$subexpression$2$subexpression$1"]},
238
- {"name": "case_arm$subexpression$2", "symbols": ["_"]},
239
- {"name": "case_arm", "symbols": ["pattern", "case_arm$subexpression$1", {"literal":"->"}, "case_arm$subexpression$2", "expression"], "postprocess": (d) => d[0] + ` -> ` + d[4]},
240
- {"name": "data_declaration$ebnf$1", "symbols": []},
241
- {"name": "data_declaration$ebnf$1$subexpression$1", "symbols": ["__", "type_variable"]},
242
- {"name": "data_declaration$ebnf$1", "symbols": ["data_declaration$ebnf$1", "data_declaration$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
243
- {"name": "data_declaration$ebnf$2", "symbols": []},
244
- {"name": "data_declaration$ebnf$2$subexpression$1", "symbols": ["_", {"literal":"|"}, "_", "constructor_def"]},
245
- {"name": "data_declaration$ebnf$2", "symbols": ["data_declaration$ebnf$2", "data_declaration$ebnf$2$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
246
- {"name": "data_declaration$ebnf$3", "symbols": ["deriving_clause"], "postprocess": id},
247
- {"name": "data_declaration$ebnf$3", "symbols": [], "postprocess": () => null},
248
- {"name": "data_declaration", "symbols": [{"literal":"data"}, "__", "constr", "data_declaration$ebnf$1", "_", {"literal":"="}, "_", "constructor_def", "data_declaration$ebnf$2", "data_declaration$ebnf$3"], "postprocess":
249
- (d) => `data ` + d[2] + (d[3] ? ` ` + d[3].map(x => x[1]).join(" ") : ``) + ` = ` + [d[7], ...d[8].map(x => `| ${x[3]}`)].join(" ") + (d[9] ?? ``)
250
- },
251
- {"name": "deriving_clause", "symbols": ["__", {"literal":"deriving"}, "_", "deriving_spec"], "postprocess": (d) => ` deriving ` + d[3]},
252
- {"name": "deriving_spec", "symbols": [{"literal":"("}, "_", "deriving_classes", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
253
- {"name": "deriving_spec", "symbols": ["constr"], "postprocess": (d) => d[0]},
254
- {"name": "deriving_classes$ebnf$1", "symbols": []},
255
- {"name": "deriving_classes$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", (HSLexer.has("typeClass") ? {type: "typeClass"} : typeClass)]},
256
- {"name": "deriving_classes$ebnf$1", "symbols": ["deriving_classes$ebnf$1", "deriving_classes$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
257
- {"name": "deriving_classes", "symbols": [(HSLexer.has("typeClass") ? {type: "typeClass"} : typeClass), "deriving_classes$ebnf$1"], "postprocess": (d) => [d[0].value, ...d[1].map(x => x[3].value)].join(", ")},
258
- {"name": "constructor_def$ebnf$1$subexpression$1", "symbols": [(HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
259
- {"name": "constructor_def$ebnf$1", "symbols": ["constructor_def$ebnf$1$subexpression$1"], "postprocess": id},
260
- {"name": "constructor_def$ebnf$1", "symbols": [], "postprocess": () => null},
261
- {"name": "constructor_def$ebnf$2$subexpression$1", "symbols": [(HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
262
- {"name": "constructor_def$ebnf$2", "symbols": ["constructor_def$ebnf$2$subexpression$1"], "postprocess": id},
263
- {"name": "constructor_def$ebnf$2", "symbols": [], "postprocess": () => null},
264
- {"name": "constructor_def$ebnf$3$subexpression$1", "symbols": [(HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
265
- {"name": "constructor_def$ebnf$3", "symbols": ["constructor_def$ebnf$3$subexpression$1"], "postprocess": id},
266
- {"name": "constructor_def$ebnf$3", "symbols": [], "postprocess": () => null},
267
- {"name": "constructor_def", "symbols": ["constr", "_", "constructor_def$ebnf$1", (HSLexer.has("lbracket") ? {type: "lbracket"} : lbracket), "_", "constructor_def$ebnf$2", "field_list", "_", "constructor_def$ebnf$3", (HSLexer.has("rbracket") ? {type: "rbracket"} : rbracket)], "postprocess": (d) => d[0] + ` { ` + d[6] + ` }`},
268
- {"name": "constructor_def$ebnf$4", "symbols": []},
269
- {"name": "constructor_def$ebnf$4$subexpression$1", "symbols": ["__", "simple_type"]},
270
- {"name": "constructor_def$ebnf$4", "symbols": ["constructor_def$ebnf$4", "constructor_def$ebnf$4$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
271
- {"name": "constructor_def", "symbols": ["constr", "constructor_def$ebnf$4"], "postprocess": (d) => [d[0], ...d[1].map(x => x[1])].join(" ")},
272
- {"name": "field_list$ebnf$1", "symbols": []},
273
- {"name": "field_list$ebnf$1$subexpression$1$ebnf$1$subexpression$1", "symbols": [(HSLexer.has("NL") ? {type: "NL"} : NL), "_"]},
274
- {"name": "field_list$ebnf$1$subexpression$1$ebnf$1", "symbols": ["field_list$ebnf$1$subexpression$1$ebnf$1$subexpression$1"], "postprocess": id},
275
- {"name": "field_list$ebnf$1$subexpression$1$ebnf$1", "symbols": [], "postprocess": () => null},
276
- {"name": "field_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "field_list$ebnf$1$subexpression$1$ebnf$1", "field"]},
277
- {"name": "field_list$ebnf$1", "symbols": ["field_list$ebnf$1", "field_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
278
- {"name": "field_list", "symbols": ["field", "field_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[4])].join(", ")},
279
- {"name": "field", "symbols": ["variable", "_", (HSLexer.has("typeEquals") ? {type: "typeEquals"} : typeEquals), "_", "type"], "postprocess": (d) => d[0] + ` :: ` + d[4]},
280
- {"name": "binding_name", "symbols": [{"literal":"("}, "_", (HSLexer.has("op") ? {type: "op"} : op), "_", {"literal":")"}], "postprocess": d => `(${d[2].value})`},
281
- {"name": "binding_name", "symbols": ["variable"], "postprocess": d => d[0]},
282
- {"name": "function_signature$ebnf$1", "symbols": []},
283
- {"name": "function_signature$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "binding_name"]},
284
- {"name": "function_signature$ebnf$1", "symbols": ["function_signature$ebnf$1", "function_signature$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
285
- {"name": "function_signature$subexpression$1", "symbols": ["_"]},
286
- {"name": "function_signature$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
287
- {"name": "function_signature$subexpression$1", "symbols": ["function_signature$subexpression$1$subexpression$1"]},
288
- {"name": "function_signature", "symbols": ["binding_name", "function_signature$ebnf$1", "_", (HSLexer.has("typeEquals") ? {type: "typeEquals"} : typeEquals), "function_signature$subexpression$1", "type"], "postprocess": (d) => [`${d[0]} :: ${d[5]}`, ...d[1].map(x => `${x[3]} :: ${d[5]}`)].join("\n")},
289
- {"name": "function_declaration", "symbols": ["variable", "equation"], "postprocess": (d) => d[0] + d[1]},
290
- {"name": "function_declaration", "symbols": [{"literal":"("}, "_", (HSLexer.has("op") ? {type: "op"} : op), "_", {"literal":")"}, "equation"], "postprocess": (d) => `(${d[2]})` + d[5]},
291
- {"name": "return_expression", "symbols": ["expression"], "postprocess": d => d[0]},
292
- {"name": "where_clause$subexpression$1", "symbols": ["_"]},
293
- {"name": "where_clause$subexpression$1$subexpression$1", "symbols": ["_", {"literal":"{"}, "_"]},
294
- {"name": "where_clause$subexpression$1", "symbols": ["where_clause$subexpression$1$subexpression$1"]},
295
- {"name": "where_clause$subexpression$1$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
296
- {"name": "where_clause$subexpression$1", "symbols": ["where_clause$subexpression$1$subexpression$2"]},
297
- {"name": "where_clause$subexpression$2", "symbols": ["_"]},
298
- {"name": "where_clause$subexpression$2$subexpression$1", "symbols": ["_", {"literal":"}"}, "_"]},
299
- {"name": "where_clause$subexpression$2", "symbols": ["where_clause$subexpression$2$subexpression$1"]},
300
- {"name": "where_clause", "symbols": [{"literal":"where"}, "where_clause$subexpression$1", "bindings_list", "where_clause$subexpression$2"], "postprocess": d => `where { ${d[2]} }`},
301
- {"name": "bindings_list$ebnf$1", "symbols": []},
302
- {"name": "bindings_list$ebnf$1$subexpression$1$subexpression$1$subexpression$1", "symbols": ["_", {"literal":";"}, "_"]},
303
- {"name": "bindings_list$ebnf$1$subexpression$1$subexpression$1", "symbols": ["bindings_list$ebnf$1$subexpression$1$subexpression$1$subexpression$1"]},
304
- {"name": "bindings_list$ebnf$1$subexpression$1$subexpression$1$subexpression$2", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
305
- {"name": "bindings_list$ebnf$1$subexpression$1$subexpression$1", "symbols": ["bindings_list$ebnf$1$subexpression$1$subexpression$1$subexpression$2"]},
306
- {"name": "bindings_list$ebnf$1$subexpression$1", "symbols": ["bindings_list$ebnf$1$subexpression$1$subexpression$1", "function_declaration"]},
307
- {"name": "bindings_list$ebnf$1", "symbols": ["bindings_list$ebnf$1", "bindings_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
308
- {"name": "bindings_list", "symbols": ["function_declaration", "bindings_list$ebnf$1"], "postprocess": d => [d[0], ...d[1].map(x => x[1])].join('; ')},
309
- {"name": "equation$ebnf$1$subexpression$1", "symbols": [(HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
310
- {"name": "equation$ebnf$1", "symbols": ["equation$ebnf$1$subexpression$1"], "postprocess": id},
311
- {"name": "equation$ebnf$1", "symbols": [], "postprocess": () => null},
312
- {"name": "equation$ebnf$2$subexpression$1$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
313
- {"name": "equation$ebnf$2$subexpression$1$subexpression$1", "symbols": ["equation$ebnf$2$subexpression$1$subexpression$1$subexpression$1"]},
314
- {"name": "equation$ebnf$2$subexpression$1$subexpression$1", "symbols": ["_"]},
315
- {"name": "equation$ebnf$2$subexpression$1", "symbols": ["equation$ebnf$2$subexpression$1$subexpression$1", "where_clause"]},
316
- {"name": "equation$ebnf$2", "symbols": ["equation$ebnf$2$subexpression$1"], "postprocess": id},
317
- {"name": "equation$ebnf$2", "symbols": [], "postprocess": () => null},
318
- {"name": "equation", "symbols": ["params", "equation$ebnf$1", "guarded_rhs", "equation$ebnf$2"], "postprocess": (d) => {
319
- const body = d[2];
320
- const whereClause = d[3] ? ` ` + d[3][1] : ``;
321
- return d[0] + ` ` + body + whereClause;
322
- } },
323
- {"name": "equation$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
324
- {"name": "equation$subexpression$1", "symbols": ["equation$subexpression$1$subexpression$1"]},
325
- {"name": "equation$subexpression$1", "symbols": ["_"]},
326
- {"name": "equation$ebnf$3$subexpression$1$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
327
- {"name": "equation$ebnf$3$subexpression$1$subexpression$1", "symbols": ["equation$ebnf$3$subexpression$1$subexpression$1$subexpression$1"]},
328
- {"name": "equation$ebnf$3$subexpression$1$subexpression$1", "symbols": ["_"]},
329
- {"name": "equation$ebnf$3$subexpression$1", "symbols": ["equation$ebnf$3$subexpression$1$subexpression$1", "where_clause"]},
330
- {"name": "equation$ebnf$3", "symbols": ["equation$ebnf$3$subexpression$1"], "postprocess": id},
331
- {"name": "equation$ebnf$3", "symbols": [], "postprocess": () => null},
332
- {"name": "equation", "symbols": ["params", (HSLexer.has("assign") ? {type: "assign"} : assign), "equation$subexpression$1", "return_expression", "equation$ebnf$3"], "postprocess": d => d[0] + ` = ` + d[3] + (d[4] ? ` ` + d[4][1] : ``)},
333
- {"name": "params", "symbols": ["__", "parameter_list", "_"], "postprocess": d => ` ${d[1]}`},
334
- {"name": "params", "symbols": ["_"], "postprocess": d => ``},
335
- {"name": "guarded_rhs$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
336
- {"name": "guarded_rhs$subexpression$1", "symbols": ["guarded_rhs$subexpression$1$subexpression$1"]},
337
- {"name": "guarded_rhs$subexpression$1", "symbols": ["_"]},
338
- {"name": "guarded_rhs", "symbols": ["guarded_branch", "guarded_rhs$subexpression$1", "guarded_rhs"], "postprocess": (d) => `${d[0]} ${d[2]}`},
339
- {"name": "guarded_rhs", "symbols": ["guarded_branch"], "postprocess": (d) => d[0]},
340
- {"name": "guarded_branch$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
341
- {"name": "guarded_branch$subexpression$1", "symbols": ["guarded_branch$subexpression$1$subexpression$1"]},
342
- {"name": "guarded_branch$subexpression$1", "symbols": ["_"]},
343
- {"name": "guarded_branch$subexpression$2$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
344
- {"name": "guarded_branch$subexpression$2", "symbols": ["guarded_branch$subexpression$2$subexpression$1"]},
345
- {"name": "guarded_branch$subexpression$2", "symbols": ["_"]},
346
- {"name": "guarded_branch$subexpression$3$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
347
- {"name": "guarded_branch$subexpression$3", "symbols": ["guarded_branch$subexpression$3$subexpression$1"]},
348
- {"name": "guarded_branch$subexpression$3", "symbols": ["_"]},
349
- {"name": "guarded_branch", "symbols": [{"literal":"|"}, "guarded_branch$subexpression$1", "condition", "guarded_branch$subexpression$2", {"literal":"="}, "guarded_branch$subexpression$3", "expression"], "postprocess": (d) => `| ${d[2]} = ${d[6]}`},
350
- {"name": "condition", "symbols": [{"literal":"otherwise"}], "postprocess": d => `otherwise`},
351
- {"name": "condition", "symbols": ["expression"], "postprocess": d => d[0]},
352
- {"name": "parameter_list$ebnf$1", "symbols": []},
353
- {"name": "parameter_list$ebnf$1$subexpression$1", "symbols": ["__", "pattern"]},
354
- {"name": "parameter_list$ebnf$1", "symbols": ["parameter_list$ebnf$1", "parameter_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
355
- {"name": "parameter_list", "symbols": ["pattern", "parameter_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[1])].join(" ")},
356
- {"name": "pattern$ebnf$1$subexpression$1", "symbols": [{"literal":"~"}, "_"]},
357
- {"name": "pattern$ebnf$1", "symbols": ["pattern$ebnf$1$subexpression$1"], "postprocess": id},
358
- {"name": "pattern$ebnf$1", "symbols": [], "postprocess": () => null},
359
- {"name": "pattern", "symbols": ["pattern$ebnf$1", "cons_pattern"], "postprocess": (d) => d[1]},
360
- {"name": "cons_pattern$ebnf$1$subexpression$1", "symbols": ["_", {"literal":":"}, "_", "cons_pattern"]},
361
- {"name": "cons_pattern$ebnf$1", "symbols": ["cons_pattern$ebnf$1$subexpression$1"]},
362
- {"name": "cons_pattern$ebnf$1$subexpression$2", "symbols": ["_", {"literal":":"}, "_", "cons_pattern"]},
363
- {"name": "cons_pattern$ebnf$1", "symbols": ["cons_pattern$ebnf$1", "cons_pattern$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
364
- {"name": "cons_pattern", "symbols": [{"literal":"("}, "_", "cons_pattern", "cons_pattern$ebnf$1", "_", {"literal":")"}], "postprocess": (d) => `(${[d[2], ...d[3].map(x => x[3])].join(":")})`},
365
- {"name": "cons_pattern", "symbols": ["simple_pattern"], "postprocess": (d) => d[0]},
366
- {"name": "simple_pattern$subexpression$1", "symbols": ["as_pattern"]},
367
- {"name": "simple_pattern$subexpression$1", "symbols": ["constructor_pattern"]},
368
- {"name": "simple_pattern$subexpression$1", "symbols": ["list_pattern"]},
369
- {"name": "simple_pattern$subexpression$1", "symbols": ["tuple_pattern"]},
370
- {"name": "simple_pattern$subexpression$1", "symbols": ["literal_pattern"]},
371
- {"name": "simple_pattern$subexpression$1", "symbols": ["variable_pattern"]},
372
- {"name": "simple_pattern$subexpression$1", "symbols": ["wildcard_pattern"]},
373
- {"name": "simple_pattern$subexpression$1", "symbols": ["paren_pattern"]},
374
- {"name": "simple_pattern", "symbols": ["simple_pattern$subexpression$1"], "postprocess": (d) => d[0][0]},
375
- {"name": "wildcard_pattern", "symbols": [(HSLexer.has("anonymousVariable") ? {type: "anonymousVariable"} : anonymousVariable)], "postprocess": (d) => `_`},
376
- {"name": "paren_pattern", "symbols": [{"literal":"("}, "_", "pattern", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
377
- {"name": "variable_pattern", "symbols": ["variable"], "postprocess": (d) => d[0]},
378
- {"name": "literal_pattern", "symbols": ["primitive"], "postprocess": (d) => d[0]},
379
- {"name": "as_pattern$subexpression$1", "symbols": ["variable_pattern"]},
380
- {"name": "as_pattern$subexpression$1", "symbols": ["wildcard_pattern"]},
381
- {"name": "as_pattern", "symbols": ["as_pattern$subexpression$1", {"literal":"@"}, "pattern"], "postprocess": (d) => d[0][0] + `@` + d[2]},
382
- {"name": "constructor_pattern$ebnf$1$subexpression$1", "symbols": ["__", "pattern"]},
383
- {"name": "constructor_pattern$ebnf$1", "symbols": ["constructor_pattern$ebnf$1$subexpression$1"]},
384
- {"name": "constructor_pattern$ebnf$1$subexpression$2", "symbols": ["__", "pattern"]},
385
- {"name": "constructor_pattern$ebnf$1", "symbols": ["constructor_pattern$ebnf$1", "constructor_pattern$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
386
- {"name": "constructor_pattern", "symbols": [{"literal":"("}, "_", "constr", "constructor_pattern$ebnf$1", "_", {"literal":")"}], "postprocess": (d) => `(${[d[2], ...d[3].map(x => x[1])].join(" ")})`},
387
- {"name": "constructor_pattern", "symbols": ["constr"], "postprocess": (d) => `${d[0]}`},
388
- {"name": "field_pattern_list$ebnf$1", "symbols": []},
389
- {"name": "field_pattern_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "field_pattern"]},
390
- {"name": "field_pattern_list$ebnf$1", "symbols": ["field_pattern_list$ebnf$1", "field_pattern_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
391
- {"name": "field_pattern_list", "symbols": ["field_pattern", "field_pattern_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])].join(`, `)},
392
- {"name": "field_pattern", "symbols": ["variable", "_", {"literal":"="}, "_", "pattern"], "postprocess": (d) => d[0] + ` = ` + d[4]},
393
- {"name": "list_pattern$ebnf$1", "symbols": ["pattern_list"], "postprocess": id},
394
- {"name": "list_pattern$ebnf$1", "symbols": [], "postprocess": () => null},
395
- {"name": "list_pattern", "symbols": [{"literal":"["}, "_", "list_pattern$ebnf$1", "_", {"literal":"]"}], "postprocess": (d) => `[${d[2] ?? ``}]`},
396
- {"name": "pattern_list$ebnf$1", "symbols": []},
397
- {"name": "pattern_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "pattern"]},
398
- {"name": "pattern_list$ebnf$1", "symbols": ["pattern_list$ebnf$1", "pattern_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
399
- {"name": "pattern_list", "symbols": ["pattern", "pattern_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])].join(`, `)},
400
- {"name": "tuple_pattern$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "pattern"]},
401
- {"name": "tuple_pattern$ebnf$1", "symbols": ["tuple_pattern$ebnf$1$subexpression$1"]},
402
- {"name": "tuple_pattern$ebnf$1$subexpression$2", "symbols": ["_", {"literal":","}, "_", "pattern"]},
403
- {"name": "tuple_pattern$ebnf$1", "symbols": ["tuple_pattern$ebnf$1", "tuple_pattern$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
404
- {"name": "tuple_pattern", "symbols": [{"literal":"("}, "_", "pattern", "tuple_pattern$ebnf$1", "_", {"literal":")"}], "postprocess": (d) => `(${[d[2], ...d[3].map(x => x[3])].join(`, `)})`},
405
- {"name": "type_declaration$ebnf$1$subexpression$1", "symbols": ["__", "variable_list"]},
406
- {"name": "type_declaration$ebnf$1", "symbols": ["type_declaration$ebnf$1$subexpression$1"], "postprocess": id},
407
- {"name": "type_declaration$ebnf$1", "symbols": [], "postprocess": () => null},
408
- {"name": "type_declaration", "symbols": [{"literal":"type"}, "__", "constr", "type_declaration$ebnf$1", "_", {"literal":"="}, "_", "type"], "postprocess": (d) => {
409
- const varList = d[3] ? ` ` + d[3][1] : ``
410
-
411
- return `type ${d[2]}` + varList + ` = ${d[7]}`
412
- } },
413
- {"name": "variable_list$ebnf$1", "symbols": []},
414
- {"name": "variable_list$ebnf$1$subexpression$1", "symbols": ["__", "variable"]},
415
- {"name": "variable_list$ebnf$1", "symbols": ["variable_list$ebnf$1", "variable_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
416
- {"name": "variable_list", "symbols": ["variable", "variable_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[1])].join(" ")},
417
- {"name": "type", "symbols": ["function_type"], "postprocess": d => d[0]},
418
- {"name": "constrained_type", "symbols": ["constraint_list", "_", (HSLexer.has("arrow") ? {type: "arrow"} : arrow), "_", "type"], "postprocess": (d) => d[0] + ` -> ` + d[4]},
419
- {"name": "context", "symbols": ["constraint"], "postprocess": (d) => d[0]},
420
- {"name": "context", "symbols": [{"literal":"("}, "_", "constraint_list", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
421
- {"name": "constraint_list$ebnf$1", "symbols": []},
422
- {"name": "constraint_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "constraint"]},
423
- {"name": "constraint_list$ebnf$1", "symbols": ["constraint_list$ebnf$1", "constraint_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
424
- {"name": "constraint_list", "symbols": ["constraint", "constraint_list$ebnf$1"], "postprocess": (d) =>
425
- [d[0], ...d[1].map(x => x[3])].join(", ")
426
- },
427
- {"name": "constraint$ebnf$1$subexpression$1", "symbols": ["_", "application_type"]},
428
- {"name": "constraint$ebnf$1", "symbols": ["constraint$ebnf$1$subexpression$1"]},
429
- {"name": "constraint$ebnf$1$subexpression$2", "symbols": ["_", "application_type"]},
430
- {"name": "constraint$ebnf$1", "symbols": ["constraint$ebnf$1", "constraint$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
431
- {"name": "constraint", "symbols": [(HSLexer.has("typeClass") ? {type: "typeClass"} : typeClass), "constraint$ebnf$1"], "postprocess": (d) => [d[0].value, ...d[1].map(x => x[1])].join(" ")},
432
- {"name": "function_type$ebnf$1$subexpression$1", "symbols": ["context", "_", (HSLexer.has("arrow") ? {type: "arrow"} : arrow), "_"]},
433
- {"name": "function_type$ebnf$1", "symbols": ["function_type$ebnf$1$subexpression$1"], "postprocess": id},
434
- {"name": "function_type$ebnf$1", "symbols": [], "postprocess": () => null},
435
- {"name": "function_type$ebnf$2", "symbols": []},
436
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$1", "symbols": ["_"]},
437
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$1$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
438
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$1", "symbols": ["function_type$ebnf$2$subexpression$1$subexpression$1$subexpression$1"]},
439
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$2", "symbols": ["_"]},
440
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$2$subexpression$1", "symbols": ["_", (HSLexer.has("NL") ? {type: "NL"} : NL), "__"]},
441
- {"name": "function_type$ebnf$2$subexpression$1$subexpression$2", "symbols": ["function_type$ebnf$2$subexpression$1$subexpression$2$subexpression$1"]},
442
- {"name": "function_type$ebnf$2$subexpression$1", "symbols": ["application_type", "function_type$ebnf$2$subexpression$1$subexpression$1", (HSLexer.has("typeArrow") ? {type: "typeArrow"} : typeArrow), "function_type$ebnf$2$subexpression$1$subexpression$2"]},
443
- {"name": "function_type$ebnf$2", "symbols": ["function_type$ebnf$2", "function_type$ebnf$2$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
444
- {"name": "function_type", "symbols": ["function_type$ebnf$1", "function_type$ebnf$2", "application_type"], "postprocess": (d) => {
445
- const constraints = d[0] ? `${d[0][0]} => ` : ``;
446
- const inputs = [...d[1].map(x => x[0]), d[2]].join(" -> ")
447
- return constraints + inputs
448
- }
449
- },
450
- {"name": "application_type$ebnf$1$subexpression$1", "symbols": ["_", "simple_type"]},
451
- {"name": "application_type$ebnf$1", "symbols": ["application_type$ebnf$1$subexpression$1"]},
452
- {"name": "application_type$ebnf$1$subexpression$2", "symbols": ["_", "simple_type"]},
453
- {"name": "application_type$ebnf$1", "symbols": ["application_type$ebnf$1", "application_type$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
454
- {"name": "application_type", "symbols": ["simple_type", "application_type$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[1])].join(" ")},
455
- {"name": "application_type", "symbols": ["simple_type"], "postprocess": (d) => d[0]},
456
- {"name": "simple_type$subexpression$1", "symbols": ["type_variable"]},
457
- {"name": "simple_type$subexpression$1", "symbols": ["type_constructor"]},
458
- {"name": "simple_type", "symbols": ["simple_type$subexpression$1"], "postprocess": (d) => d[0][0]},
459
- {"name": "simple_type", "symbols": [{"literal":"["}, "_", "type", "_", {"literal":"]"}], "postprocess": (d) => `[${d[2]}]`},
460
- {"name": "simple_type$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "type"]},
461
- {"name": "simple_type$ebnf$1", "symbols": ["simple_type$ebnf$1$subexpression$1"]},
462
- {"name": "simple_type$ebnf$1$subexpression$2", "symbols": ["_", {"literal":","}, "_", "type"]},
463
- {"name": "simple_type$ebnf$1", "symbols": ["simple_type$ebnf$1", "simple_type$ebnf$1$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])},
464
- {"name": "simple_type", "symbols": [{"literal":"("}, "_", "type", "simple_type$ebnf$1", "_", {"literal":")"}], "postprocess": (d) => `(${[d[2], ...d[3].map(x => x[3])].join(`, `)})`},
465
- {"name": "simple_type", "symbols": [{"literal":"("}, "_", "type", "_", {"literal":")"}], "postprocess": (d) => `(${d[2]})`},
466
- {"name": "type_variable", "symbols": ["variable"], "postprocess": (d) => d[0]},
467
- {"name": "type_constructor", "symbols": ["constr"], "postprocess": (d) => d[0]},
468
- {"name": "constr", "symbols": [(HSLexer.has("constructor") ? {type: "constructor"} : constructor)], "postprocess": (d) => `${d[0].value}`},
469
- {"name": "variable", "symbols": [(HSLexer.has("variable") ? {type: "variable"} : variable)], "postprocess": (d) => `${d[0].value}`},
470
- {"name": "list_literal", "symbols": [{"literal":"["}, "_", {"literal":"]"}], "postprocess": (d) => `[]`},
471
- {"name": "list_literal", "symbols": [{"literal":"["}, "_", "expression_list", "_", {"literal":"]"}], "postprocess": (d) => `[${d[2]}]`},
472
- {"name": "range_expression", "symbols": ["expression", "_", {"literal":".."}], "postprocess": (d) => d[0] + ".."},
473
- {"name": "range_expression", "symbols": ["expression", "_", {"literal":".."}, "_", "expression"], "postprocess": (d) => d[0] + ".." + d[4]},
474
- {"name": "range_expression", "symbols": ["expression", "_", {"literal":","}, "_", "expression", "_", {"literal":".."}], "postprocess": (d) => d[0] + ", " + d[4] + ".."},
475
- {"name": "range_expression", "symbols": ["expression", "_", {"literal":","}, "_", "expression", "_", {"literal":".."}, "_", "expression"], "postprocess": (d) => d[0] + ", " + d[4] + ".." + d[6]},
476
- {"name": "expression_list$ebnf$1", "symbols": []},
477
- {"name": "expression_list$ebnf$1$subexpression$1", "symbols": ["_", {"literal":","}, "_", "expression"]},
478
- {"name": "expression_list$ebnf$1", "symbols": ["expression_list$ebnf$1", "expression_list$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]])},
479
- {"name": "expression_list", "symbols": ["expression", "expression_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map(x => x[3])].join(`, `)},
480
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":"=="}]},
481
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":"/="}]},
482
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":"<"}]},
483
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":">"}]},
484
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":"<="}]},
485
- {"name": "comparison_operator$subexpression$1", "symbols": [{"literal":">="}]},
486
- {"name": "comparison_operator", "symbols": ["comparison_operator$subexpression$1"], "postprocess": (d) => d[0][0].value},
487
- {"name": "primitive$subexpression$1", "symbols": [(HSLexer.has("number") ? {type: "number"} : number)]},
488
- {"name": "primitive$subexpression$1", "symbols": [(HSLexer.has("char") ? {type: "char"} : char)]},
489
- {"name": "primitive$subexpression$1", "symbols": [(HSLexer.has("string") ? {type: "string"} : string)]},
490
- {"name": "primitive$subexpression$1", "symbols": [(HSLexer.has("bool") ? {type: "bool"} : bool)]},
491
- {"name": "primitive", "symbols": ["primitive$subexpression$1"], "postprocess": (d) => `${d[0][0].value}`},
492
- {"name": "_$ebnf$1", "symbols": []},
493
- {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", (HSLexer.has("WS") ? {type: "WS"} : WS)], "postprocess": (d) => d[0].concat([d[1]])},
494
- {"name": "_", "symbols": ["_$ebnf$1"]},
495
- {"name": "__$ebnf$1", "symbols": [(HSLexer.has("WS") ? {type: "WS"} : WS)]},
496
- {"name": "__$ebnf$1", "symbols": ["__$ebnf$1", (HSLexer.has("WS") ? {type: "WS"} : WS)], "postprocess": (d) => d[0].concat([d[1]])},
497
- {"name": "__", "symbols": ["__$ebnf$1"]}
498
- ],
499
- ParserStart: "program",
500
- };
501
-
502
- export default grammar;