-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.ebnf
68 lines (51 loc) · 2.71 KB
/
grammar.ebnf
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
/* The root rule for parsing a Simple Widget Annotation (SWA) */
<SWA> ::= <Whitespace> <TokenChain> <Whitespace>
/* A chain of tokens, connected through '>' or '>[]' or '[]' */
<TokenChain> ::= <Token> <Whitespace> ">" <Whitespace> <TokenChain>
| <Token> (<Whitespace> | <Whitespace> ">" <Whitespace>) "[" <Whitespace> <TokenList> <Whitespace> "]" <Whitespace>
| <Token>
/* A list of tokens separated by ',' */
<TokenList> ::= <TokenChain> <Whitespace> "," <Whitespace> <TokenList>
| <TokenChain>
/* The main token rule, either a widget with/without parameters */
<Token> ::= <FunctionCall> | <Identifier>
/* Dart-related rules for more flexible expressions */
<Expression> ::= <DartStringLiteral>
| <FunctionCall>
| <Ternary>
| <AnonymousFunc>
| <ArrayLiteral>
| <TokenChain>
/* Function Calls */
<FunctionCall> ::= <Identifier> <Whitespace> <Generics>? <Whitespace> "(" <Whitespace> <ParameterList>? <Whitespace> ")"
/* Generics Expression */
<Generics> ::= "<" <Whitespace> <TypeList> <Whitespace> ">"
/* TypeList in Generics */
<TypeList> ::= <Identifier> <Whitespace> "," <Whitespace> <TypeList>
| <Identifier>
/* A list of parameters, includes named parameters */
<ParameterList> ::= <Parameter> <Whitespace> "," <Whitespace> <ParameterList>
| <Parameter>
/* A single parameter can be a Dart expression, a nested parameter, a body expression, or a named parameter */
<Parameter> ::= <NamedParameter> | <Token> | <Expression>
/* Named parameters */
<NamedParameter> ::= <Identifier> <Whitespace> ":" <Whitespace> <Parameter>
/* Conditional Expression */
<Ternary> ::= <Expression> <Whitespace> "?" <Whitespace> <Token> <Whitespace> ":" <Whitespace> <Token>
/* Anonymous Functions */
<AnonymousFunc> ::= "(" <Whitespace> <ParameterList>? <Whitespace> ")" <Whitespace> "=>" <Whitespace> <Token>
/* Array Literal */
<ArrayLiteral> ::= "[" <Whitespace> <ArrayLiteralList>? <Whitespace> "]"
/* Array Literal List */
<ArrayLiteralList> ::= <Expression> <Whitespace> "," <Whitespace> <ArrayLiteralList>
| <Expression>
/* Dart String literals */
<DartDoubleQuoteStringLiteralContent> ::= <AlphaNumChar> | "'" | " "
<DartSingleQuoteStringLiteralContent> ::= <AlphaNumChar> | "\"" | " "
<DartStringLiteral> ::= "\"" <DartDoubleQuoteStringLiteralContent>* "\"" | "'" <DartSingleQuoteStringLiteralContent>* "'"
/* Dart-related character classifications */
<IdentifierChain> ::= <Identifier> <Whitespace> "." <Whitespace> <IdentifierChain> | <Identifier>
<Identifier> ::= <AlphaNumChar>+
/* Character classifications */
<AlphaNumChar> ::= [a-z] | [A-Z] | [0-9]
<Whitespace> ::= (" " | "\n")*