1 %option case-insensitive
5 %s mediaquery at_rule block
9 unicode \\{h}{1,6}[ \t\r\n\f]?
10 escape {unicode}|\\[ -~\200-\377]
11 nmstart [_a-zA-Z]|{nonascii}|{escape}
12 nmchar [_a-zA-Z0-9-]|{nonascii}|{escape}
13 string1 \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
14 string2 \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
15 hexcolor {h}{3}|{h}{6}
17 ident -?{nmstart}{nmchar}*
19 num [0-9]+|[0-9]*"."[0-9]+
21 string {string1}|{string2}
22 url ([!#$%&*-~]|{nonascii}|{escape})*
25 range \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
26 nth (-?[0-9]*n[\+-][0-9]+)|(-?[0-9]*n)
30 \/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
32 [ \t\r\n\f]+ {yyTok = S; return yyTok;}
34 "<!--" {yyTok = SGML_CD; return yyTok;}
35 "-->" {yyTok = SGML_CD; return yyTok;}
36 "~=" {yyTok = INCLUDES; return yyTok;}
37 "|=" {yyTok = DASHMATCH; return yyTok;}
38 "^=" {yyTok = BEGINSWITH; return yyTok;}
39 "$=" {yyTok = ENDSWITH; return yyTok;}
40 "*=" {yyTok = CONTAINS; return yyTok;}
41 <mediaquery>"not" {yyTok = MEDIA_NOT; return yyTok;}
42 <mediaquery>"only" {yyTok = MEDIA_ONLY; return yyTok;}
43 <mediaquery>"and" {yyTok = MEDIA_AND; return yyTok;}
45 {string} {yyTok = STRING; return yyTok;}
46 {ident} {yyTok = IDENT; return yyTok;}
47 {nth} {yyTok = NTH; return yyTok;}
50 <block>"#"{hexcolor} {yyTok = HEXCOLOR; return yyTok;}
51 "#"{ident} {yyTok = HASH; return yyTok;}
53 /* @rule tokens surrounding css declaration blocks with { } braces must start a BEGIN(at_rule) context */
54 "@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;}
55 "@page" {BEGIN(at_rule); yyTok = PAGE_SYM; return yyTok;}
56 "@media" {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;}
57 "@font-face" {BEGIN(at_rule); yyTok = FONT_FACE_SYM; return yyTok;}
58 "@charset" {BEGIN(at_rule); yyTok = CHARSET_SYM; return yyTok;}
59 "@namespace" {BEGIN(at_rule); yyTok = NAMESPACE_SYM; return yyTok; }
60 "@-khtml-rule" {BEGIN(at_rule); yyTok = KHTML_RULE_SYM; return yyTok; }
61 "@-khtml-decls" {yyTok = KHTML_DECLS_SYM; return yyTok; }
62 "@-khtml-value" {yyTok = KHTML_VALUE_SYM; return yyTok; }
63 "@-khtml-mediaquery" {BEGIN(mediaquery); yyTok = KHTML_MEDIAQUERY_SYM; return yyTok; }
65 "!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;}
67 {num}em {yyTok = EMS; return yyTok;}
68 {num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */
69 {num}ex {yyTok = EXS; return yyTok;}
70 {num}px {yyTok = PXS; return yyTok;}
71 {num}cm {yyTok = CMS; return yyTok;}
72 {num}mm {yyTok = MMS; return yyTok;}
73 {num}in {yyTok = INS; return yyTok;}
74 {num}pt {yyTok = PTS; return yyTok;}
75 {num}pc {yyTok = PCS; return yyTok;}
76 {num}deg {yyTok = DEGS; return yyTok;}
77 {num}rad {yyTok = RADS; return yyTok;}
78 {num}grad {yyTok = GRADS; return yyTok;}
79 {num}ms {yyTok = MSECS; return yyTok;}
80 {num}s {yyTok = SECS; return yyTok;}
81 {num}Hz {yyTok = HERZ; return yyTok;}
82 <mediaquery>{num}dpi {yyTok = DPI; return yyTok;}
83 <mediaquery>{num}dpcm {yyTok = DPCM; return yyTok;}
84 {num}kHz {yyTok = KHERZ; return yyTok;}
85 {num}{ident} {yyTok = DIMEN; return yyTok;}
86 {num}% {yyTok = PERCENTAGE; return yyTok;}
87 {intnum} {yyTok = INTEGER; return yyTok;}
88 {num} {yyTok = FLOAT; return yyTok;}
91 "not(" {yyTok = NOTFUNCTION; return yyTok;}
92 "url("{w}{string}{w}")" {yyTok = URI; return yyTok;}
93 "url("{w}{url}{w}")" {yyTok = URI; return yyTok;}
94 {ident}"(" {yyTok = FUNCTION; return yyTok;}
96 U\+{range} {yyTok = UNICODERANGE; return yyTok;}
97 U\+{h}{1,6}-{h}{1,6} {yyTok = UNICODERANGE; return yyTok;}
99 <INITIAL>"{" {BEGIN(block); yyTok = *yytext; return yyTok;}
104 <mediaquery>";" {BEGIN(INITIAL); yyTok = *yytext; return yyTok; }
105 . {yyTok = *yytext; return yyTok;}