/
extract.glue
359 lines (359 loc) · 14.2 KB
/
extract.glue
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
importG
variableDeclaration ::= declaredIdentifier ("," identifier)*;
declaredIdentifier ::= metadata finalConstVarOrType identifier;
finalConstVarOrType ::= "final" type?
| "const" type?
| varOrType;
varOrType ::= "var"
| type;
initializedVariableDeclaration ::= declaredIdentifier ("=" expression)? ("," initializedIdentifier)*;
initializedIdentifier ::= identifier ("=" expression)?;
initializedIdentifierList ::= initializedIdentifier ("," initializedIdentifier)*;
functionSignature ::= metadata returnType? identifier formalParameterList;
returnType ::= "void"
| type;
functionBody ::= "=>" expression ";"
| block;
block ::= "{" statements "}";
formalParameterList ::= "(" ")"
| "(" normalFormalParameters ( "," optionalFormalParameters)? ")"
| "(" optionalFormalParameters ")";
normalFormalParameters ::= normalFormalParameter ("," normalFormalParameter)*;
optionalFormalParameters ::= optionalPositionalFormalParameters
| namedFormalParameters;
optionalPositionalFormalParameters ::= "[" defaultFormalParameter ("," defaultFormalParameter)* "]";
namedFormalParameters ::= "{" defaultNamedParameter ("," defaultNamedParameter)* "}";
normalFormalParameter ::= functionSignature
| fieldFormalParameter
| simpleFormalParameter;
simpleFormalParameter ::= declaredIdentifier
| metadata identifier;
fieldFormalParameter ::= metadata finalConstVarOrType? "this" "." identifier formalParameterList?;
defaultFormalParameter ::= normalFormalParameter ("=" expression)?;
defaultNamedParameter ::= normalFormalParameter ( ":" expression)?;
classDefinition ::= metadata "abstract" ? "class" identifier typeParameters? (superclass mixins?)? interfaces? "{" (metadata classMemberDefinition)* "}"
| metadata "abstract" ? "class" mixinApplicationClass;
mixins ::= "with" typeList;
classMemberDefinition ::= declaration ";"
| methodSignature functionBody;
methodSignature ::= constructorSignature initializers?
| factoryConstructorSignature
| "static" ? functionSignature
| "static" ? getterSignature
| "static" ? setterSignature
| operatorSignature;
declaration ::= constantConstructorSignature (redirection | initializers)?
| constructorSignature (redirection | initializers)?
| "external" constantConstructorSignature
| "external" constructorSignature
| (( "external" "static" ?))? getterSignature
| (( "external" "static" ?))? setterSignature
| "external" ? operatorSignature
| (( "external" "static" ?))? functionSignature
| "static" ( "final" | "const" ) type? staticFinalDeclarationList
| "const" type? staticFinalDeclarationList
| "final" type? initializedIdentifierList
| "static" ? ( "var" | type) initializedIdentifierList;
staticFinalDeclarationList ::= staticFinalDeclaration ("," staticFinalDeclaration)*;
staticFinalDeclaration ::= identifier "=" expression;
operatorSignature ::= returnType? "operator" operator formalParameterList;
operator ::= "~"
| binaryOperator
| "[" "]"
| "[" "]" "=";
binaryOperator ::= multiplicativeOperator
| additiveOperator
| shiftOperator
| relationalOperator
| "=="
| bitwiseOperator;
getterSignature ::= type? "get" identifier;
setterSignature ::= returnType? "set" identifier formalParameterList;
constructorSignature ::= identifier ("." identifier)? formalParameterList;
redirection ::= ":" "this" ("." identifier)? arguments;
initializers ::= ":" superCallOrFieldInitializer ("," superCallOrFieldInitializer)*;
superCallOrFieldInitializer ::= "super" arguments
| "super" "." identifier arguments
| fieldInitializer;
fieldInitializer ::= ( "this" ".")? identifier "=" conditionalExpression cascadeSection*;
factoryConstructorSignature ::= "factory" identifier ("." identifier)? formalParameterList;
redirectingFactoryConstructorSignature ::= "const" ? "factory" identifier ("." identifier)? formalParameterList "=" type ("." identifier)?;
constantConstructorSignature ::= "const" qualified formalParameterList;
superclass ::= "extends" type;
interfaces ::= "implements" typeList;
mixinApplicationClass ::= identifier typeParameters? "=" mixinApplication ";";
mixinApplication ::= type mixins interfaces?;
typeParameter ::= metadata identifier ( "extends" type)?;
typeParameters ::= "<" typeParameter ("," typeParameter)* ">";
metadata ::= ("@" qualified ("."identifier)? (arguments)?)*;
expression ::= assignableExpression assignmentOperator expression
| conditionalExpression cascadeSection*
| throwExpression;
expressionWithoutCascade ::= assignableExpression assignmentOperator expressionWithoutCascade
| conditionalExpression
| throwExpressionWithoutCascade;
expressionList ::= expression ("," expression)*;
primary ::= thisExpression
| "super" assignableSelector
| functionExpression
| literal
| identifier
| newExpression
| constObjectExpression
| "(" expression ")";
literal ::= nullLiteral
| booleanLiteral
| numericLiteral
| stringLiteral
| symbolLiteral
| mapLiteral
| listLiteral;
nullLiteral ::= "null";
numericLiteral ::= NUMBER
| HEX_NUMBER;
NUMBER ::= DIGIT+ ("." DIGIT+)? EXPONENT?
| "." DIGIT+ EXPONENT?;
EXPONENT ::= ("e" | "E") ("+" | "-")? DIGIT+;
HEX_NUMBER ::= "0x" HEX_DIGIT+
| "0X" HEX_DIGIT+;
HEX_DIGIT ::= "a"|"b"|"c"|"d"|"e"|"f"
| "A"|"B"|"C"|"D"|"E"|"F"
| DIGIT;
booleanLiteral ::= "true"
| "false";
stringLiteral ::= (multilineString | singleLineString)+;
singleLineString ::= DQUOTE stringContentDQ* DQUOTE
| DQUOTE stringContentSQ* DQUOTE
| "r" DQUOTE (¬( DQUOTE | NEWLINE ))* DQUOTE
| "r" DQUOTE (¬( DQUOTE | NEWLINE ))* DQUOTE;
multilineString ::= TDQUOTE stringContentTDQ* TDQUOTE
| TDQUOTE stringContentTSQ* TDQUOTE
| "r" TDQUOTE (¬ TDQUOTE)* TDQUOTE
| "r" TDQUOTE (¬ TDQUOTE)* TDQUOTE;
ESCAPE_SEQUENCE ::= "\n"
| "\r"
| "\f"
| "\b"
| "\t"
| "\v"
| "\x" HEX_DIGIT HEX_DIGIT
| "\u" HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
| "\u{" HEX_DIGIT_SEQUENCE "}";
HEX_DIGIT_SEQUENCE ::= HEX_DIGIT HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT?;
stringContentDQ ::= ¬( "\" | DQUOTE | "$" | NEWLINE )
| "\" ¬( NEWLINE )
| stringInterpolation;
stringContentSQ ::= ¬( "\" | DQUOTE | "$" | NEWLINE )
| "\" ¬( NEWLINE )
| stringInterpolation;
stringContentTDQ ::= ¬( "\" | TDQUOTE | "$")
| stringInterpolation;
stringContentTSQ ::= ¬( "\" | TDQUOTE | "$")
| stringInterpolation;
NEWLINE ::= "\n"
| "\r";
stringInterpolation ::= "$" IDENTIFIER_NO_DOLLAR
| "$" "{" expression "}";
symbolLiteral ::= "#" (operator | (identifier ("." identifier)*));
listLiteral ::= "const" ? typeArguments? "[" (expressionList ","?)? "]";
mapLiteral ::= "const" ? typeArguments? "{" (mapLiteralEntry ("," mapLiteralEntry)* ","?)? "}";
mapLiteralEntry ::= expression ":" expression;
throwExpression ::= "throw" expression;
throwExpressionWithoutCascade ::= "throw" expressionWithoutCascade;
functionExpression ::= formalParameterList functionExpressionBody;
functionExpressionBody ::= "=>" expression
| block;
thisExpression ::= "this";
newExpression ::= "new" type ("." identifier)? arguments;
constObjectExpression ::= "const" type ("." identifier)? arguments;
arguments ::= "(" argumentList? ")";
argumentList ::= namedArgument ("," namedArgument)*
| expressionList ("," namedArgument)*;
namedArgument ::= label expression;
cascadeSection ::= ".." (cascadeSelector arguments*) (assignableSelector arguments*)* (assignmentOperator expressionWithoutCascade)?;
cascadeSelector ::= "[" expression "]"
| identifier;
assignmentOperator ::= "="
| compoundAssignmentOperator;
compoundAssignmentOperator ::= "*="
| "/="
| "~/="
| "%="
| "+="
| "-="
| "<<="
| ">>="
| "&="
| "^="
| "|=";
conditionalExpression ::= logicalOrExpression ("?" expressionWithoutCascade ":" expressionWithoutCascade)?;
logicalOrExpression ::= logicalAndExpression ("||" logicalAndExpression)*;
logicalAndExpression ::= equalityExpression ("&&" equalityExpression)*;
equalityExpression ::= relationalExpression (equalityOperator relationalExpression)?
| "super" equalityOperator relationalExpression;
equalityOperator ::= "=="
| "!=";
relationalExpression ::= bitwiseOrExpression (typeTest | typeCast | relationalOperator bitwiseOrExpression)?
| "super" relationalOperator bitwiseOrExpression;
relationalOperator ::= ">="
| ">"
| "<="
| "<";
bitwiseOrExpression ::= bitwiseXorExpression ("|" bitwiseXorExpression)*
| "super" ("|" bitwiseXorExpression)+;
bitwiseXorExpression ::= bitwiseAndExpression ("^" bitwiseAndExpression)*
| "super" ("^" bitwiseAndExpression)+;
bitwiseAndExpression ::= shiftExpression ("&" shiftExpression)*
| "super" ("&" shiftExpression)+;
bitwiseOperator ::= "&"
| "^"
| "|";
shiftExpression ::= additiveExpression (shiftOperator additiveExpression)*
| "super" (shiftOperator additiveExpression)+;
shiftOperator ::= "<<"
| ">>";
additiveExpression ::= multiplicativeExpression (additiveOperator multiplicativeExpression)*
| "super" (additiveOperator multiplicativeExpression)+;
additiveOperator ::= "+"
| "-";
multiplicativeExpression ::= unaryExpression (multiplicativeOperator unaryExpression)*
| "super" (multiplicativeOperator unaryExpression)+;
multiplicativeOperator ::= "*"
| "/"
| "%"
| "~/";
unaryExpression ::= prefixOperator unaryExpression
| postfixExpression
| prefixOperator "super"
| incrementOperator assignableExpression;
prefixOperator ::= "-"
| unaryOperator;
unaryOperator ::= "!"
| "~";
postfixExpression ::= assignableExpression postfixOperator
| primary selector*;
postfixOperator ::= incrementOperator;
selector ::= assignableSelector
| arguments;
incrementOperator ::= "++"
| "--";
assignableExpression ::= primary (argument* assignableSelector)+
| "super" assignableSelector
| identifier;
assignableSelector ::= "[" expression "]"
| "." identifier;
identifier ::= IDENTIFIER;
IDENTIFIER_NO_DOLLAR ::= IDENTIFIER_START_NO_DOLLAR IDENTIFIER_PART_NO_DOLLAR*;
IDENTIFIER ::= IDENTIFIER_START IDENTIFIER_PART*;
BUILT_IN_IDENTIFIER ::= "abstract"
| "as"
| "dynamic"
| "export"
| "external"
| "factory"
| "get"
| "implements"
| "import"
| "library"
| "operator"
| "part"
| "set"
| "static"
| "typedef";
IDENTIFIER_START ::= IDENTIFIER_START_NO_DOLLAR
| "$";
IDENTIFIER_START_NO_DOLLAR ::= LETTER
| "_";
IDENTIFIER_PART_NO_DOLLAR ::= IDENTIFIER_START_NO_DOLLAR
| DIGIT;
IDENTIFIER_PART ::= IDENTIFIER_START
| DIGIT;
qualified ::= identifier ("." identifier)?;
typeTest ::= isOperator type;
isOperator ::= "is" "!"?;
typeCast ::= asOperator type;
asOperator ::= "as";
statements ::= statement*;
statement ::= label* nonLabelledStatement;
nonLabelledStatement ::= block
| localVariableDeclaration
| forStatement
| whileStatement
| doStatement
| switchStatement
| ifStatement
| rethrowStatement
| tryStatement
| breakStatement
| continueStatement
| returnStatement
| expressionStatement
| assertStatement
| localFunctionDeclaration;
expressionStatement ::= expression? ";";
localVariableDeclaration ::= initializedVariableDeclaration";";
localFunctionDeclaration ::= functionSignature functionBody;
ifStatement ::= "if" "(" expression ")" statement ( "else" statement)?;
forStatement ::= "for" "(" forLoopParts ")" statement;
forLoopParts ::= forInitializerStatement expression? ";" expressionList?
| declaredIdentifier "in" expression
| identifier "in" expression;
forInitializerStatement ::= localVariableDeclaration ";"
| expression? ";";
whileStatement ::= "while" "(" expression ")" statement;
doStatement ::= "do" statement "while" "(" expression ")" ";";
switchStatement ::= "switch" "(" expression ")" "{" switchCase* defaultCase? "}";
switchCase ::= label* ( "case" expression ":") statements;
defaultCase ::= label* "default" ":" statements;
rethrowStatement ::= "rethrow";
tryStatement ::= "try" block (onPart+ finallyPart? | finallyPart);
onPart ::= catchPart block
| "on" type catchPart? block;
catchPart ::= "catch" "(" identifier ("," identifier)? ")";
finallyPart ::= "finally" block;
returnStatement ::= "return" expression? ";";
label ::= identifier ":";
breakStatement ::= "break" identifier? ";";
continueStatement ::= "continue" identifier? ";";
assertStatement ::= assert "(" conditionalExpression ")" ";";
topLevelDefinition ::= classDefinition
| typeAlias
| "external" ? functionSignature ";"
| "external" ? getterSignature ";"
| "external" ? setterSignature ";"
| functionSignature functionBody
| returnType? getOrSet identifier formalParameterList functionBody
| ( "final" | "const" ) type? staticFinalDeclarationList ";"
| variableDeclaration ";";
getOrSet ::= "get"
| "set";
libraryDefinition ::= scriptTag? libraryName? importOrExport* partDirective* topLevelDefinition*;
scriptTag ::= "#!"(¬NEWLINE)*NEWLINE;
libraryName ::= metadata "library" identifier ("." identifier)* ";";
importOrExport ::= libraryImport
| libraryExport;
libraryImport ::= metadata "import" uri ( "as" identifier)? combinator* ";";
combinator ::= "show" identifierList
| "hide" identifierList;
identifierList ::= identifier ("," identifier)*;
libraryExport ::= metadata "export" uri combinator* ";";
partDirective ::= metadata "part" uri ";";
partHeader ::= metadata "part" "of" identifier ("." identifier)* ";";
partDeclaration ::= partHeader topLevelDefinition* EOF;
uri ::= stringLiteral;
type ::= typeName typeArguments?;
typeName ::= qualified;
typeArguments ::= "<" typeList ">";
typeList ::= type ("," type)*;
typeAlias ::= metadata "typedef" typeAliasBody;
typeAliasBody ::= functionTypeAlias;
functionTypeAlias ::= functionPrefix typeParameters? formalParameterList ";";
functionPrefix ::= returnType? identifier;
LETTER ::= "a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z"
| "A"|"B"|"C"|"D"|"E"|"F"|"G"|"H"|"I"|"J"|"K"|"L"|"M"|"N"|"O"|"P"|"Q"|"R"|"S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z";
DIGIT ::= "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9";
WHITESPACE ::= ("\t" | " " | NEWLINE)+;
SINGLE_LINE_COMMENT ::= "//" ¬(NEWLINE)* (NEWLINE)?;
MULTI_LINE_COMMENT ::= "/*" (MULTI_LINE_COMMENT | ¬ "*/")* "*/";
.
export BGF |home:///projects/webzoo-prep/zoo/dart/latex/v11.0/extracted/grammar.bgf|.