-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGRAMMAR
More file actions
66 lines (65 loc) · 1.17 KB
/
GRAMMAR
File metadata and controls
66 lines (65 loc) · 1.17 KB
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
*: 0 or more
+: 1 or more
?: 0 or 1
|: separates alternatives
[ ]: grouping
stylesheet
: S* [ rule? S* ]*
;
rule
: selectors '{' S* [ declarations | rule ]* '}' S*
;
selectors
: selector [ ',' S* selector ]*
;
selector
: simple_selector [ combinator selector | S+ [ combinator? selector ]? ]?
;
simple_selector
: element_name [ HASH | class | attrib | pseudo ]* | [ HASH | class | attrib | pseudo ]+
;
element_name
: AMPERSAND | CARET | IDENT | '*'
;
class
: '.' IDENT
;
attrib
: '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ]? ']'
;
pseudo
: ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ]
;
declarations
: declaration? [ ';' S* declaration? ]*
;
declaration
: property ':' S* expr prio?
;
prio
: IMPORTANT_SYM S*
;
operator
: '/' S* | ',' S*
;
combinator
: '+' S* | '>' S*
;
unary_operator
: '-' | '+'
;
property
: IDENT S*
;
expr
: term [ operator? term ]*
;
term
: unary_operator? [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* ] | STRING S* | IDENT S* | URI S* | hexcolor | function
;
function
: FUNCTION S* expr ')' S*
;
hexcolor
: HASH S*
;