-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgrammar.ebnf
66 lines (49 loc) · 2.25 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
attribute name = /[^\s\/>"\'=]+/;
string = /"[^"\n]+"|'[^'\n]+'/;
variable = /\$[a-z_]\w*/;
any character except line break and outdent = -(line break | outdent);
static text = { any character except line break and outdent }
variable text = { static text | variable | ('{', expression, '}') };
block of static text = {static text}, [line break, indent, {static text, [line break]}, outdent];
block of variable text = {variable text}, [line break, indent, {variable text, [line break]}, outdent];
text block = '|', block of variable text;
variable block = '=', ['='], (variable | expression), [text block];
language name = 'css' | 'js';
code block = language name, ':', block of static text;
tag identifier = [tag name], [tag id], {tag class}
| [tag name], {tag class}, [tag id];
name = letter, {letter | digit | '-', '_'};
tag name = name;
tag id = '#', name;
tag class = '.', name;
child blocks = line break, indent, {template block}, outdent;
inline block = ':', template block;
content block = text block
| variable block
| yield block
| inline block
| child blocks;
attribute value = string | variable;
attribute = attribute name, ['=', [ '=' | '?' ], attribute value];
tag block = tag identifier, {attribute}, [content block];
html block = '<', block of variable text;
yield block = '-', name, [content block];
section block = '@', name, [content block];
include block = '+', name, {'.', name}, {attribute}, [content block];
extend block = '_', name, {'.', name}, {attribute}, [content block];
comment block = '/', ['!'], block of variable text;
iteration block = '>', (variable | expression), ['>', [ variable ]], content block;
conditional block = ('?' | '!'), expression, child blocks;
template block = code block
| tag block
| text block
| html block
| yield block
| extend block
| section block
| include block
| comment block
| variable block
| iteration block
| conditional block;
template = {template block, {line break}};