1 %option case-insensitive 2 %option noyywrap 3 %option 8bit 4 %option stack 5 %s mediaquery 6 %s forkeyword 7 8 h [0-9a-fA-F] 9 nonascii [\200-\377] 10 unicode \\{h}{1,6}[ \t\r\n\f]? 11 escape {unicode}|\\[ -~\200-\377] 12 nmstart [_a-zA-Z]|{nonascii}|{escape} 13 nmchar [_a-zA-Z0-9-]|{nonascii}|{escape} 14 string1 \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\" 15 string2 \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\' 16 hexcolor {h}{3}|{h}{6} 17 18 ident -?{nmstart}{nmchar}* 19 name {nmchar}+ 20 num [0-9]+|[0-9]*"."[0-9]+ 21 intnum [0-9]+ 22 string {string1}|{string2} 23 url ([!#$%&*-~]|{nonascii}|{escape})* 24 w [ \t\r\n\f]* 25 nl \n|\r\n|\r|\f 26 range \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h}))))) 27 nth (-?[0-9]*n[\+-][0-9]+)|(-?[0-9]*n) 28 29 %% 30 31 \/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */ 32 33 [ \t\r\n\f]+ {yyTok = WHITESPACE; return yyTok;} 34 35 "<!--" {yyTok = SGML_CD; return yyTok;} 36 "-->" {yyTok = SGML_CD; return yyTok;} 37 "~=" {yyTok = INCLUDES; return yyTok;} 38 "|=" {yyTok = DASHMATCH; return yyTok;} 39 "^=" {yyTok = BEGINSWITH; return yyTok;} 40 "$=" {yyTok = ENDSWITH; return yyTok;} 41 "*=" {yyTok = CONTAINS; return yyTok;} 42 <mediaquery>"not" {yyTok = MEDIA_NOT; return yyTok;} 43 <mediaquery>"only" {yyTok = MEDIA_ONLY; return yyTok;} 44 <mediaquery>"and" {yyTok = MEDIA_AND; return yyTok;} 45 <forkeyword>"for" {BEGIN(mediaquery); yyTok = VARIABLES_FOR; return yyTok; } 46 47 {string} {yyTok = STRING; return yyTok;} 48 {ident} {yyTok = IDENT; return yyTok;} 49 {nth} {yyTok = NTH; return yyTok;} 50 51 "#"{hexcolor} {yyTok = HEX; return yyTok;} 52 "#"{ident} {yyTok = IDSEL; return yyTok;} 53 54 "@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;} 55 "@page" {yyTok = PAGE_SYM; return yyTok;} 56 "@media" {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;} 57 "@font-face" {yyTok = FONT_FACE_SYM; return yyTok;} 58 "@charset" {yyTok = CHARSET_SYM; return yyTok;} 59 "@namespace" {yyTok = NAMESPACE_SYM; return yyTok; } 60 "@-webkit-rule" {yyTok = WEBKIT_RULE_SYM; return yyTok; } 61 "@-webkit-decls" {yyTok = WEBKIT_DECLS_SYM; return yyTok; } 62 "@-webkit-value" {yyTok = WEBKIT_VALUE_SYM; return yyTok; } 63 "@-webkit-mediaquery" {BEGIN(mediaquery); yyTok = WEBKIT_MEDIAQUERY_SYM; return yyTok; } 64 "@-webkit-selector" {yyTok = WEBKIT_SELECTOR_SYM; return yyTok; } 65 "@-webkit-variables" {BEGIN(mediaquery); yyTok = WEBKIT_VARIABLES_SYM; return yyTok; } 66 "@-webkit-define" {BEGIN(forkeyword); yyTok = WEBKIT_DEFINE_SYM; return yyTok; } 67 "@-webkit-variables-decls" { yyTok = WEBKIT_VARIABLES_DECLS_SYM; return yyTok; } 68 "@-webkit-keyframes" {yyTok = WEBKIT_KEYFRAMES_SYM; return yyTok; } 69 "@-webkit-keyframe-rule" {yyTok = WEBKIT_KEYFRAME_RULE_SYM; return yyTok; } 70 71 "@"{ident} {yyTok = ATKEYWORD; return yyTok; } 72 73 "!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;} 74 75 {num}em {yyTok = EMS; return yyTok;} 76 {num}rem {yyTok = REMS; return yyTok;} 77 {num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */ 78 {num}ex {yyTok = EXS; return yyTok;} 79 {num}px {yyTok = PXS; return yyTok;} 80 {num}cm {yyTok = CMS; return yyTok;} 81 {num}mm {yyTok = MMS; return yyTok;} 82 {num}in {yyTok = INS; return yyTok;} 83 {num}pt {yyTok = PTS; return yyTok;} 84 {num}pc {yyTok = PCS; return yyTok;} 85 {num}deg {yyTok = DEGS; return yyTok;} 86 {num}rad {yyTok = RADS; return yyTok;} 87 {num}grad {yyTok = GRADS; return yyTok;} 88 {num}turn {yyTok = TURNS; return yyTok;} 89 {num}ms {yyTok = MSECS; return yyTok;} 90 {num}s {yyTok = SECS; return yyTok;} 91 {num}Hz {yyTok = HERZ; return yyTok;} 92 {num}kHz {yyTok = KHERZ; return yyTok;} 93 {num}{ident} {yyTok = DIMEN; return yyTok;} 94 {num}%+ {yyTok = PERCENTAGE; return yyTok;} 95 {intnum} {yyTok = INTEGER; return yyTok;} 96 {num} {yyTok = FLOATTOKEN; return yyTok;} 97 98 "not(" {yyTok = NOTFUNCTION; return yyTok;} 99 "url("{w}{string}{w}")" {yyTok = URI; return yyTok;} 100 "url("{w}{url}{w}")" {yyTok = URI; return yyTok;} 101 "-webkit-var("{w}{ident}{w}")" { yyTok = VARCALL; return yyTok; } 102 {ident}"(" {yyTok = FUNCTION; return yyTok;} 103 104 U\+{range} {yyTok = UNICODERANGE; return yyTok;} 105 U\+{h}{1,6}-{h}{1,6} {yyTok = UNICODERANGE; return yyTok;} 106 107 <mediaquery>"{" | 108 <mediaquery>";" {BEGIN(INITIAL); yyTok = *yytext; return yyTok; } 109 . {yyTok = *yytext; return yyTok;} 110 111 %% 112