1 %option case-insensitive 2 %option noyywrap 3 %option noyyalloc noyyrealloc 4 %option never-interactive 5 %option nounput 6 %option reentrant 7 8 %top{ 9 /* config.h must precede flex's inclusion of <stdio.h> 10 in order for its _GNU_SOURCE definition to take effect. */ 11 #include <config.h> 12 } 13 14 %{ 15 16 #define YY_NO_INPUT 17 18 #include <wget.h> 19 20 #include "css_tokenizer.h" 21 22 #if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) 23 #pragma GCC diagnostic ignored "-Wunknown-pragmas" // clang mourns about the next one 24 #pragma GCC diagnostic ignored "-Wunused-function" 25 #pragma GCC diagnostic ignored "-Wunused-macros" 26 #pragma GCC diagnostic ignored "-Wunused-parameter" 27 #pragma GCC diagnostic ignored "-Wsign-compare" 28 #pragma GCC diagnostic ignored "-Wswitch-default" 29 #pragma clang diagnostic ignored "-Wunreachable-code" 30 #pragma clang diagnostic ignored "-Wshorten-64-to-32" 31 #pragma clang diagnostic ignored "-Wextra-semi-stmt" 32 #ifndef __clang__ 33 #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" 34 #endif 35 #endif 36 37 %} 38 39 h [0-9a-f] 40 nonascii [\240-\377] 41 unicode \\{h}{1,6}(\r\n|[ \t\r\n\f])? 42 escape {unicode}|\\[^\r\n\f0-9a-f] 43 nmstart [_a-z]|{nonascii}|{escape} 44 nmchar [_a-z0-9-]|{nonascii}|{escape} 45 string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\" 46 string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\' 47 badstring1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\\? 48 badstring2 \'([^\n\r\f\\']|\\{nl}|{escape})*\\? 49 badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)* 50 badcomment2 \/\*[^*]*(\*+[^/*][^*]*)* 51 baduri1 url\({w}([!#$%&*-\[\]-~]|{nonascii}|{escape})*{w} 52 baduri2 url\({w}{string}{w} 53 baduri3 url\({w}{badstring} 54 comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/ 55 ident -?{nmstart}{nmchar}* 56 name {nmchar}+ 57 num [0-9]+|[0-9]*"."[0-9]+ 58 string {string1}|{string2} 59 badstring {badstring1}|{badstring2} 60 badcomment {badcomment1}|{badcomment2} 61 baduri {baduri1}|{baduri2}|{baduri3} 62 url ([!#$%&*-~]|{nonascii}|{escape})* 63 s [ \t\r\n\f]+ 64 w {s}? 65 nl \n|\r\n|\r|\f 66 67 A a|\\0{0,4}(41|61)(\r\n|[ \t\r\n\f])? 68 C c|\\0{0,4}(43|63)(\r\n|[ \t\r\n\f])? 69 D d|\\0{0,4}(44|64)(\r\n|[ \t\r\n\f])? 70 E e|\\0{0,4}(45|65)(\r\n|[ \t\r\n\f])? 71 G g|\\0{0,4}(47|67)(\r\n|[ \t\r\n\f])?|\\g 72 H h|\\0{0,4}(48|68)(\r\n|[ \t\r\n\f])?|\\h 73 I i|\\0{0,4}(49|69)(\r\n|[ \t\r\n\f])?|\\i 74 K k|\\0{0,4}(4b|6b)(\r\n|[ \t\r\n\f])?|\\k 75 L l|\\0{0,4}(4c|6c)(\r\n|[ \t\r\n\f])?|\\l 76 M m|\\0{0,4}(4d|6d)(\r\n|[ \t\r\n\f])?|\\m 77 N n|\\0{0,4}(4e|6e)(\r\n|[ \t\r\n\f])?|\\n 78 O o|\\0{0,4}(4f|6f)(\r\n|[ \t\r\n\f])?|\\o 79 P p|\\0{0,4}(50|70)(\r\n|[ \t\r\n\f])?|\\p 80 R r|\\0{0,4}(52|72)(\r\n|[ \t\r\n\f])?|\\r 81 S s|\\0{0,4}(53|73)(\r\n|[ \t\r\n\f])?|\\s 82 T t|\\0{0,4}(54|74)(\r\n|[ \t\r\n\f])?|\\t 83 U u|\\0{0,4}(55|75)(\r\n|[ \t\r\n\f])?|\\u 84 X x|\\0{0,4}(58|78)(\r\n|[ \t\r\n\f])?|\\x 85 Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z 86 87 %% 88 89 {s} {return S;} 90 91 {comment} {return COMMENT;} 92 #\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */ 93 {badcomment} /* unclosed comment at EOF */ 94 95 "<!--" {return CDO;} 96 "-->" {return CDC;} 97 "~=" {return INCLUDES;} 98 "|=" {return DASHMATCH;} 99 100 {string} {return STRING;} 101 {badstring} {return BAD_STRING;} 102 103 {ident} {return IDENT;} 104 105 "#"{name} {return HASH;} 106 107 @{I}{M}{P}{O}{R}{T} {return IMPORT_SYM;} 108 @{P}{A}{G}{E} {return PAGE_SYM;} 109 @{M}{E}{D}{I}{A} {return MEDIA_SYM;} 110 "@charset " {return CHARSET_SYM;} 111 112 "!"({w}|{comment})*{I}{M}{P}{O}{R}{T}{A}{N}{T} {return IMPORTANT_SYM;} 113 114 {num}{E}{M} {return EMS;} 115 {num}{E}{X} {return EXS;} 116 {num}{P}{X} {return LENGTH;} 117 {num}{C}{M} {return LENGTH;} 118 {num}{M}{M} {return LENGTH;} 119 {num}{I}{N} {return LENGTH;} 120 {num}{P}{T} {return LENGTH;} 121 {num}{P}{C} {return LENGTH;} 122 {num}{D}{E}{G} {return ANGLE;} 123 {num}{R}{A}{D} {return ANGLE;} 124 {num}{G}{R}{A}{D} {return ANGLE;} 125 {num}{M}{S} {return TIME;} 126 {num}{S} {return TIME;} 127 {num}{H}{Z} {return FREQ;} 128 {num}{K}{H}{Z} {return FREQ;} 129 {num}{ident} {return DIMENSION;} 130 131 {num}% {return PERCENTAGE;} 132 {num} {return NUMBER;} 133 134 "url("{w}{string}{w}")" {return URI;} 135 "url("{w}{url}{w}")" {return URI;} 136 {baduri} {return BAD_URI;} 137 138 {ident}"(" {return FUNCTION;} 139 140 . {return *yytext;} 141 142 %% 143