123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- # CSS1 parser for a PEG parser generator.
- # and a user command parser
- # Doesn't support import statements.
- STYLESHEET ← (CDO / CDC)* (RULESET/DECLARATIONS/COMMENT/ATRULE)* (CDO / CDC)*
- RULESET ← SELECTORS "{" DECLARATIONS? "}"
- SELECTORS ← SELECTOR ("," SELECTOR)*
- SELECTOR ← ( "*" / NAME ID? CLASS? PSEUDO_CLASS? /
- ID CLASS? PSEUDO_CLASS? /
- CLASS PSEUDO_CLASS? /
- PSEUDO_CLASS )+ PSEUDO_ELEMENT* / PSEUDO_ELEMENT
- ATRULE ← ATID (STRING / URL) ";" / ATID "{" DECLARATIONS "}"
- NAME ← <IDENT>
- DECLARATIONS ← DECLARATION (';' DECLARATION)* ';'?
- DECLARATION ← NAME ":" EXPR PRIO? / COMMENT
- OPERATOR ← '/' / ','
- # UNARY_OPERATOR ← '-' / '+'
- PRIO ← IMPORTANT
- EXPR ← TERM (OPERATOR TERM)*
- TERM ← STRING / PERCENTAGE / LENGTH / HEXCOLOR / URL / RGB / NUM / IDENT
- ~COMMENT ← "/*" (!("*/").)* "*/"
- ATID ← < "@" [a-zA-Z][-_a-zA-Z0-9]+ >
- IMPORTANT ← < "!" WS "important" >
- IDENT ← < [-_a-zA-Z][-_a-zA-Z0-9]* >
- PERCENTAGE ← < NUM > "%"
- NUM ← < [+-]*[0-9]+ / [0-9]* "." [0-9]+ >
- LENGTH ← NUM UNIT
- UNIT ← <"pt" / "mm" / "pt" / "in" / "px" / "em" / "ex" >
- PSEUDO_ELEMENT ← <":first-letter" / ":first-line" >
- PSEUDO_CLASS ← <":hover" / ":link" / ":mark" / ":active" / ":visited" >
- HEXCOLOR ← "#" < ([0-9a-fA-F])+ >
- ID ← "#" < IDENT >
- CLASS ← "." < IDENT >
- # Raw string macro.
- RAWSM(O,C) ← O < (!(C).)* > C
- # Escaped string macro.
- ESCSM(O,C) ← O < (!(C)STRCHAR)* > C
- # String escapes
- STRESC1 ← "\\" [nrtfv\'\\"\[\]\\]
- STRESC2 ← "\\" [0-3] [0-7] [0-7]
- STRESC3 ← "\\" [0-7] [0-7]*
- STRESC4 ← "\\x" [0-9a-fA-F] [0-9a-fA-F]?
- STRESC5 ← "\\u" [0-9a-fA-F]+
- STRNOESC ← (!('\\\\').)
- STRCHAR ← STRESC1 / STRESC2 / STRESC3 / STRESC4 / STRESC5 / STRNOESC
- # Strings
- STRING ← ESCSM("\"", "\"") / ESCSM("'", "'")
- URL ← "url(" STRING ")"
- RGB ← < "rgb("[ \t]*[0-9]+[ \t]* "," [ \t]*[0-9]+[ \t]* "," [ \t]*[0-9]+[ \t]* ")" >
- ~WS ← [ \t\n\r]*
- CDO ← "<!--"
- CDC ← "-->"
- %whitespace ← [ \t\n\r]*
- # %word ← [a-zA-Z][-+/*_a-zA-Z0-9]*
|