yukigo-haskell-parser 0.1.0

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