-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
66 lines (47 loc) · 1.43 KB
/
grammar.txt
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
csscrape -> statement_list
statement_list -> statement statement_list
| ""
statement -> ID `:` rvalue filter_list `;`
rvalue -> element
| leaf
element -> maybe_url selector_list `{` statement_list `}` qualifier
inline -> `<` leaf filter_list `>`
maybe_url -> inline
| ""
selector -> selector_fragment selector_combinator_list
# TODO: pseudo-class, attr
named_selector -> `.` ID
| `#` ID
| ID
# must be nonempty
named_selector_list -> named_selector named_selector_list2
named_selector_list2 -> named_selector named_selector_list2
| ""
selector_fragment -> named_selector_list
| `*`
selector_combinator_list -> selector_combinator selector_fragment selector_combinator_list
| ""
selector_combinator -> `+`
| `>`
| `~`
| `,` # can we wrap in parentheses? i don't think so.
| ""
qualifier -> `?`
| `*`
| ""
filter_list -> `|` filter qualifier filter_list
| ""
filter -> ID `(` arg_list `)`
| `[` ID `:` leaf filter_list `]`
value -> leaf
| inline
arg_list -> ID `:` value arg_list2
| ""
# allow optional trailing comma
arg_list2 -> `,` arg_list
| ""
leaf -> variable
| INT
| FLOAT
| STRING
variable -> `$` ID