This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.auto.ts
76 lines (61 loc) · 1.96 KB
/
Parser.auto.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*----------------------------------------------------------------/
| WARNING: Do not manually update this file!
| It is auto-generated via
| <@chharvey/parser//src/main.ts>.
| If you need to make updates, make them there.
/----------------------------------------------------------------*/
import type {
NonemptyArray,
} from '../../src/types.d';
import type {Token} from '../../src/lexer/Token';
import {ParseNode} from '../../src/parser/ParseNode';
import {Parser} from '../../src/parser/Parser';
import {Production} from '../../src/grammar/Production';
import {
Grammar,
GrammarSymbol,
} from '../../src/grammar/Grammar';
import {LEXER} from './Lexer';
import * as TERMINAL from './Terminal';
class ProductionUnit extends Production {
static readonly instance: ProductionUnit = new ProductionUnit();
override get sequences(): NonemptyArray<NonemptyArray<GrammarSymbol>> {
return [
[TERMINAL.TerminalNumber.instance],
['(', TERMINAL.TerminalOperator.instance, ProductionUnit.instance, ProductionUnit.instance, ')'],
];
}
}
class ProductionGoal extends Production {
static readonly instance: ProductionGoal = new ProductionGoal();
override get sequences(): NonemptyArray<NonemptyArray<GrammarSymbol>> {
return [
['\u0002', '\u0003'],
['\u0002', ProductionUnit.instance, '\u0003'],
];
}
}
export class ParseNodeUnit extends ParseNode {
declare readonly children:
| readonly [Token]
| readonly [Token, Token, ParseNodeUnit, ParseNodeUnit, Token]
;
}
export class ParseNodeGoal extends ParseNode {
declare readonly children:
| readonly [Token, Token]
| readonly [Token, ParseNodeUnit, Token]
;
}
export const GRAMMAR: Grammar = new Grammar([
ProductionUnit.instance,
ProductionGoal.instance,
], ProductionGoal.instance);
export const PARSER: Parser<ParseNodeGoal> = new Parser<ParseNodeGoal>(
LEXER,
GRAMMAR,
new Map<Production, typeof ParseNode>([
[ProductionUnit.instance, ParseNodeUnit],
[ProductionGoal.instance, ParseNodeGoal],
]),
);