-
Notifications
You must be signed in to change notification settings - Fork 0
/
jamgram.astir
110 lines (96 loc) · 3.06 KB
/
jamgram.astir
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
finite automaton JamTokenizer {
ignored root WhiteSpace = [' ' '\n' '\r' '\t' ]+;
root NotEqual = "!=";
root Not = "!";
root LogicalAnd = "&&";
root And = "&";
root LeftParen = "(";
root RightParen = ")";
root Append = "+=";
root Colon = ":";
root SemiColon = ";";
root LessOrEqual = "<=";
root LessThan = "<";
root Equals = "=";
root GreaterOrEqual = ">=";
root GreaterThan = ">";
root DefaultAssign = "?=";
root LeftBracket = "[";
root RightBracket = "]";
root LeftBrace = "{";
root Or = "|";
root LogicalOr = "||";
root RightBrace = "}";
root Actions = "actions";
root Bind = "bind";
root Break = "break";
root Case = "case";
root Continue = "continue";
root Default = "default";
root Else = "else";
root Existing = "existing";
root For = "for";
root If = "if";
root Ignore = "ignore";
root In = "in";
root Include = "include";
root JumpToEof = "jumptoeof";
root Local = "local";
root Maxline = "maxline";
root On = "on";
root Piecemeal = "piecemeal";
root Quietly = "quietly";
root Return = "return";
root Rule = "rule";
root Switch = "switch";
root Together = "together";
root Update = "updated";
root While = "while";
root String = [^ ' ' '\n' '\r' '\t']+;
}
LL(finite) parser JamParser with ambiguity_resolved_by_precedence on JamTokenizer {
root category JamRules;
production ListOfRules : JamRules = JamRule*;
production LocalRules : JamRules = Local List? SemiColon JamRules*;
production LocalAssignedRules : JamRules = Local List? Equals List? SemiColon JamRules*;
root category JamRule;
production BlockRule : JamRule = LeftBrace JamRules* RightBrace;
production IncludeRUle : JamRule = Include List SemiColon;
production JumpToEofRule : JamRule = JumpToEof List SemiColon;
production ArgumentsRule : JamRule = Argument ListOfLists SemiColon;
production AssignArgumentRule : JamRule = Argument Assignment List SemiColon;
production OnArgumentRule : JamRule = Argument On List Assignment List SemiColon;
production BreakRule : JamRule = Break List? SemiColon;
production ContinueRule : JamRule = Continue List? SemiColon;
production ReturnRule : JamRule = Return List? SemiColon;
production ForRule : JamRule = For Argument In List LeftBrace JamRules RightBrace;
production SwitchRule : JamRule = Switch List LeftBrace CaseStatement* RightBrace;
// if expr { block }
// if expr { block } else rule
// while expr { block }
production RuleRule : JamRule = Rule Argument Parameters? LeftBrace JamRules* RightBrace;
production OnRule : JamRule = On Argument JamRule;
// actions eflags arg bindlist { /* scan string? */ string /* scan normal? */ }
production List = String List*;
production ListOfLists
= List?
| List Colon ListOfLists
;
production Argument
= String
| LeftBracket Function RightBracket
;
production Function
= Argument ListOfLists
| On Argument Argument ListOfLists
| On Argument Return List
;
production Assignment
= Equals
| Append
| DefaultAssign
| Default Equals
;
production CaseStatement = Case Argument Colon JamRules*;
production Parameters = Argument | Argument Colon Parameters;
}