This repository was archived by the owner on May 20, 2019. It is now read-only.
forked from hoaproject/Compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammar.pp2
More file actions
108 lines (85 loc) · 1.94 KB
/
grammar.pp2
File metadata and controls
108 lines (85 loc) · 1.94 KB
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
%include lexer
#Grammar
: __definition()*
;
__definition
: TokenDefinition()
| PragmaDefinition()
| IncludeDefinition()
| RuleDefinition()
;
/**
| ---------------------------------------------------------------------------------
| List of root structure definitions
| ---------------------------------------------------------------------------------
*/
#TokenDefinition -> Railt\Compiler\Grammar\Delegate\TokenDelegate
: <T_TOKEN>
| <T_SKIP>
;
#PragmaDefinition
: <T_PRAGMA>
;
#IncludeDefinition -> Railt\Compiler\Grammar\Delegate\IncludeDelegate
: <T_INCLUDE>
;
/**
| ---------------------------------------------------------------------------------
| Rule Definition
| ---------------------------------------------------------------------------------
*/
#RuleDefinition -> Railt\Compiler\Grammar\Delegate\RuleDelegate
: ShouldKeep()? RuleName() RuleDelegate()?
::T_EQ:: RuleProduction() ::T_END_OF_RULE::?
;
#RuleName
: <T_NAME>
;
#RuleDelegate
: ::T_DELEGATE:: <T_NAME>
;
#ShouldKeep
: ::T_KEPT_NAME::
;
#RuleProduction
: __alternation()
;
__alternation
: __concatenation()
| Alternation()
;
#Alternation
: __concatenation() ( <T_OR> __concatenation() )+
;
__concatenation
: __repetition()
| Concatenation()
;
#Concatenation
: __repetition() __repetition()+
;
__repetition
: ( __simple() | Repetition() ) Rename()?
;
#Repetition
: __simple() Quantifier()
;
__simple
: <T_GROUP_OPEN> __alternation() <T_GROUP_CLOSE>
| <T_TOKEN_SKIPPED>
| <T_TOKEN_KEPT>
| <T_TOKEN_STRING>
| <T_INVOKE>
;
#Quantifier
: <T_REPEAT_ZERO_OR_ONE>
| <T_REPEAT_ONE_OR_MORE>
| <T_REPEAT_ZERO_OR_MORE>
| <T_REPEAT_N_TO_M>
| <T_REPEAT_ZERO_OR_MORE>
| <T_REPEAT_ZERO_TO_M>
| <T_REPEAT_N_OR_MORE>
| <T_REPEAT_EXACTLY_N>
;
#Rename
: <T_KEPT_NAME> <T_NAME>