-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.hx
67 lines (62 loc) · 2.67 KB
/
Parser.hx
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
/*
* Generated by the Waxeye Parser Generator - version 0.8.1
* www.waxeye.org
*/
package;
import org.waxeye.parser.*;
import org.waxeye.parser.Exp.ExpType;
import org.waxeye.parser.Modes;
//import haxe.ds.StringMap;
/**
* A parser generated by the Waxeye Parser Generator.
*
* @author Waxeye Parser Generator
*/
class Parser extends org.waxeye.parser.Parser
{
/**
* Creates a new Parser.
*/
public function new()
{
super(makeDefinition(), 'calc');
}
/**
* Builds the grammar definitions for the parser.
*
* @return The definitions grammar for the parser.
*/
@:keep
private function makeDefinition():Dynamic
{
var def:Dynamic = {calc : {'mode' : Modes.NORMAL, 'exp' : new Exp(ExpType.SEQ, [new Exp(ExpType.NT, ['ws']),
new Exp(ExpType.NT, ['sum'])]) },
sum : {'mode' : Modes.NORMAL, 'exp' : new Exp(ExpType.SEQ, [new Exp(ExpType.NT, ['prod']),
new Exp(ExpType.STAR, [new Exp(ExpType.SEQ, [new Exp(ExpType.CHAR_CLASS, ['+',
'-']),
new Exp(ExpType.NT, ['ws']),
new Exp(ExpType.NT, ['prod'])])])]) },
prod : {'mode' : Modes.NORMAL, 'exp' : new Exp(ExpType.SEQ, [new Exp(ExpType.NT, ['unary']),
new Exp(ExpType.STAR, [new Exp(ExpType.SEQ, [new Exp(ExpType.CHAR_CLASS, ['*',
'/']),
new Exp(ExpType.NT, ['ws']),
new Exp(ExpType.NT, ['unary'])])])]) },
unary : {'mode' : Modes.PRUNING, 'exp' : new Exp(ExpType.ALT, [new Exp(ExpType.SEQ, [new Exp(ExpType.CHAR, ['-']),
new Exp(ExpType.NT, ['ws']),
new Exp(ExpType.NT, ['unary'])]),
new Exp(ExpType.SEQ, [new Exp(ExpType.VOID, [new Exp(ExpType.CHAR, ['('])]),
new Exp(ExpType.NT, ['ws']),
new Exp(ExpType.NT, ['sum']),
new Exp(ExpType.VOID, [new Exp(ExpType.CHAR, [')'])]),
new Exp(ExpType.NT, ['ws'])]),
new Exp(ExpType.NT, ['num'])]) },
num : {'mode' : Modes.NORMAL, 'exp' : new Exp(ExpType.SEQ, [new Exp(ExpType.PLUS, [new Exp(ExpType.CHAR_CLASS, [['0', '9']])]),
new Exp(ExpType.OPT, [new Exp(ExpType.SEQ, [new Exp(ExpType.CHAR, ['.']),
new Exp(ExpType.PLUS, [new Exp(ExpType.CHAR_CLASS, [['0', '9']])])])]),
new Exp(ExpType.NT, ['ws'])]) },
ws : {'mode' : Modes.VOIDING, 'exp' : new Exp(ExpType.STAR, [new Exp(ExpType.CHAR_CLASS, [['\t', '\n'],
'\r',
' '])]) }}
return def;
}
}