forked from tvandijck/Frustel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GOLD Meta-Language (5.2.0).grm
198 lines (153 loc) · 4.56 KB
/
GOLD Meta-Language (5.2.0).grm
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
!-----------------------------------------------------------------------------------
! GOLD Meta-Language
!
! This is the very simple grammar used to define grammars using the GOLD Parser.
! The grammar was revised for version 5.2.0 of the GOLD Parser Builder.
! It was reverse engineered from the gp.dat that comes with the binaries.
!
! www.devincook.com/goldparser
! -----------------------------------------------------------------------------------
"Name" = 'GOLD Meta-Language'
"Version" = '5.2.0'
"Author" = 'Devin Cook'
"About" = 'This grammar defines the GOLD Meta-Language.'
"Start Symbol" = <Grammar>
! ====================================================================
! Special Terminals
! ====================================================================
{Parameter Ch} = {Printable} - ["] - ['']
{Nonterminal Ch} = {Alphanumeric} + [_-.] + {Space}
{Literal Ch} = {Printable} - [''] !Basically anything, DO NOT CHANGE!
{Set Literal Ch} = {Printable} - ['['']'] - ['']
{Id Head} = {Letter} + [_]
{Id Tail} = {Id Head} + {Digit}
{Hex Digit} = {Digit} + [abcdefABCDEF]
DecNumber = {Digit}+
HexNumber = '0x'{Hex Digit}+
Identifier = {Id Head}{Id Tail}*
Literal = '' {Literal Ch}* ''
Nonterminal = '<' {Nonterminal Ch}+ '>'
ParameterName = '"' {Parameter Ch}+ '"'
SetLiteral = '[' ({Set Literal Ch} | '' {Literal Ch}* '' )+ ']'
! ====================================================================
! Line-Based Grammar Declarations
! ====================================================================
{Whitespace Ch} = {Whitespace} - {CR} - {LF}
Whitespace = {Whitespace Ch}+
Newline = {CR}{LF} | {CR} | {LF}
! ====================================================================
! Comments
! ====================================================================
Comment Line = '!'
Comment Start = '!*'
Comment End = '*!'
! ====================================================================
! Rules
! ====================================================================
<Grammar>
::= <nlo> <Content>
<Content>
::= <Content> <Definition>
| <Definition>
<Definition>
::= <Param>
| <Attribute Decl>
| <Set Decl>
| <Group Decl>
| <Terminal Decl>
| <Rule Decl>
<nlo>
::= Newline <nlo>
|
<nl>
::= Newline <nl>
| Newline
<Terminal Name>
::= Identifier
| Literal
<Value List>
::= <Value List> ',' <nlo> <Value Items>
| <Value Items>
<Value Items>
::= <Value Items> <Value Item>
| <Value Item>
<Value Item>
::= Identifier
| Nonterminal
| Literal
<Param>
::= ParameterName <nlo> '=' <Param Body> <nl>
<Param Body>
::= <Param Body> <nlo> '|' <Value List>
| <Value List>
<Attribute Decl>
::= <Terminal Name> <nlo> '@=' '{' <Attribute List> '}' <nl>
| <Terminal Name> Identifier <nlo> '@=' '{' <Attribute List> '}' <nl>
<Attribute List>
::= <Attribute List> ',' <nlo> <Attribute Item>
| <Attribute Item>
<Attribute Item>
::= Identifier '=' Identifier
| Identifier '=' '{' <Value List> '}'
<Set Decl>
::= '{' <ID Series> '}' <nlo> '=' <Set Exp> <nl>
<Set Exp>
::= <Set Exp> <nlo> '+' <Set Item>
| <Set Exp> <nlo> '-' <Set Item>
| <Set Item>
<Set Item>
::= SetLiteral
| '{' <ID Series> '}'
| '{' <Charcode List> '}'
<ID Series>
::= <ID Series> Identifier
| Identifier
<Charcode List>
::= <Charcode List> ',' <nlo> <Charcode Item>
| <Charcode Item>
<Charcode Item>
::= <Charcode Value>
| <Charcode Value> '..' <Charcode Value>
<Charcode Value>
::= HexNumber
| DecNumber
<Group Decl>
::= <Terminal Name> Identifier <nlo> '=' <Group Item> <nl>
<Group Item>
::= Identifier
| Literal
<Terminal Decl>
::= <Terminal Name> <nlo> '=' <Terminal Body> <nl>
<Terminal Body>
::= <Terminal Body> <nlo> '|' <Reg Exp Seq>
| <Reg Exp Seq>
<Reg Exp Seq>
::= <Reg Exp Seq> <Reg Exp Item>
| <Reg Exp Item>
<Reg Exp Item>
::= <Set Item> <Kleene Opt>
| Literal <Kleene Opt>
| Identifier <Kleene Opt>
| '(' <Sub Reg Exp> ')' <Kleene Opt>
<Sub Reg Exp>
::= <Sub Reg Exp> '|' <Reg Exp Seq>
| <Reg Exp Seq>
<Kleene Opt>
::= '+'
| '?'
| '*'
|
<Rule Decl>
::= Nonterminal <nlo> '::=' <Handles> <nl>
<Handles>
::= <Handles> <nlo> '|' <Handle>
| <Handle>
<Handle>
::= <Symbols>
| '<>'
<Symbols>
::= <Symbols> <Symbol>
|
<Symbol>
::= <Terminal Name>
| Nonterminal