-
Notifications
You must be signed in to change notification settings - Fork 2
/
tree-sitter-svelte.ebnf
153 lines (109 loc) · 2.83 KB
/
tree-sitter-svelte.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
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
//
// From tree-sitter-svelte/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
document ::=
_node*
_node ::=
script_element
| style_element
| _statement
_statement ::=
comment
| _text
| element
| if_statement
| key_statement
| each_statement
| await_statement
element ::=
start_tag _node* ( end_tag | _implicit_end_tag )
| self_closing_tag
start_tag ::=
'<' _start_tag_name attribute* '>'
self_closing_tag ::=
'<' _start_tag_name attribute* '/>'
end_tag ::=
'</' _end_tag_name '>'
erroneous_end_tag ::=
'</' erroneous_end_tag_name '>'
script_element ::=
script_start_tag raw_text? end_tag
script_start_tag ::=
'<' _script_start_tag_name attribute* '>'
style_element ::=
style_start_tag raw_text? end_tag
style_start_tag ::=
'<' _style_start_tag_name attribute* '>'
attribute ::=
attribute_name ( '=' ( attribute_value | quoted_attribute_value | expr_attribute_value ) )?
| expression
attribute_name ::=
[^<>{}"'/= #x09#x0A#x0B#x0C#x0D]+
attribute_value ::=
[^<>{}"'/= #x09#x0A#x0B#x0C#x0D]+
expr_attribute_value ::=
expression
quoted_attribute_value ::=
"'" [^']+? "'"
| '"' [^"]+? '"'
_text ::=
[^<>{} #x09#x0A#x0B#x0C#x0D]([^<>{}]*[^<>{} #x09#x0A#x0B#x0C#x0D])?
| _expression
_expression ::=
expression
| html_expr
| const_expr
| '{}'
expression ::=
'{' raw_text_expr '}'
html_expr ::=
'{' '@' 'html' raw_text_expr? '}'
const_expr ::=
'{' '@' 'const' raw_text_expr? '}'
if_statement ::=
if_start_expr _node* ( else_if_statement | else_statement | if_end_expr )
else_if_statement ::=
else_if_expr _node* ( if_end_expr | else_statement | else_if_statement )
else_statement ::=
else_expr _node* if_end_expr
if_start_expr ::=
'{' '#' 'if' raw_text_expr '}'
else_expr ::=
'{' ':' 'else' '}'
else_if_expr ::=
'{' ':' 'else' 'if' raw_text_expr? '}'
if_end_expr ::=
'{' '/' 'if' '}'
each_statement ::=
each_start_expr _node* ( else_each_statement | each_end_expr )
each_start_expr ::=
'{' '#' 'each' ( raw_text_expr | raw_text_each 'as' raw_text_expr ) '}'
else_each_statement ::=
else_expr _node* each_end_expr
each_end_expr ::=
'{' '/' 'each' '}'
await_statement ::=
await_start_expr _node* ( then_statement | catch_statement | await_end_expr )
then_statement ::=
then_expr _node* ( await_end_expr | catch_statement )
catch_statement ::=
catch_expr _node* await_end_expr
await_start_expr ::=
'{' '#' 'await' ( raw_text_expr | raw_text_await 'then' raw_text_expr ) '}'
then_expr ::=
'{' ':' 'then' raw_text_expr? '}'
catch_expr ::=
'{' ':' 'catch' raw_text_expr? '}'
await_end_expr ::=
'{' '/' 'await' '}'
key_statement ::=
key_start_expr _node* key_end_expr
key_start_expr ::=
'{' '#' 'key' ( raw_text_expr ) '}'
key_end_expr ::=
'{' '/' 'key' '}'