Debian Codegraph @

src/css.l

raw
1 %option case-insensitive
2 %option noyywrap
3 %option never-interactive
4 %option nounput
5
6 %top{
7 /* config.h must precede flex's inclusion of <stdio.h>
8 in order for its _GNU_SOURCE definition to take effect. */
9 #include <config.h>
10 }
11
12 %{
13 /* Lex source for CSS tokenizing.
14 Taken from http://www.w3.org/TR/CSS21/grammar.html#q2
15 Copyright (C) 2006, 2009-2011, 2015, 2018-2024 Free Software
16 Foundation, Inc.
17
18 This file is part of GNU Wget.
19
20 GNU Wget is free software; you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation; either version 3 of the License, or (at
23 your option) any later version.
24
25 GNU Wget is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
29
30 You should have received a copy of the GNU General Public License
31 along with Wget. If not, see <http://www.gnu.org/licenses/>.
32
33 Additional permission under GNU GPL version 3 section 7
34
35 If you modify this program, or any covered work, by linking or
36 combining it with the OpenSSL project's OpenSSL library (or a
37 modified version of that library), containing parts covered by the
38 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
39 grants you additional permission to convey the resulting work.
40 Corresponding Source for a non-source form of such a combination
41 shall include the source code for the parts of OpenSSL used as well
42 as that of the covered work. */
43
44 #define YY_NO_INPUT
45
46 #include "css-tokens.h"
47
48 #if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
49 #pragma GCC diagnostic ignored "-Wunknown-pragmas" // clang mourns about the next one
50 #pragma GCC diagnostic ignored "-Wunused-function"
51 #pragma GCC diagnostic ignored "-Wunused-macros"
52 #pragma GCC diagnostic ignored "-Wunused-parameter"
53 #pragma GCC diagnostic ignored "-Wsign-compare"
54 #pragma GCC diagnostic ignored "-Wswitch-default"
55 #pragma GCC diagnostic ignored "-Wunreachable-code" // clang
56 #pragma clang diagnostic ignored "-Wshorten-64-to-32"
57 #ifndef __clang__
58 #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
59 #endif
60 #endif
61
62 %}
63
64 h [0-9a-f]
65 nonascii [\240-\377]
66 unicode \\{h}{1,6}(\r\n|[ \t\r\n\f])?
67 escape {unicode}|\\[^\r\n\f0-9a-f]
68 nmstart [_a-z]|{nonascii}|{escape}
69 nmchar [_a-z0-9-]|{nonascii}|{escape}
70 string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
71 string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\'
72 badstring1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\\?
73 badstring2 \'([^\n\r\f\\']|\\{nl}|{escape})*\\?
74 badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)*
75 badcomment2 \/\*[^*]*(\*+[^/*][^*]*)*
76 baduri1 url\({w}([!#$%&*-\[\]-~]|{nonascii}|{escape})*{w}
77 baduri2 url\({w}{string}{w}
78 baduri3 url\({w}{badstring}
79 comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/
80 ident -?{nmstart}{nmchar}*
81 name {nmchar}+
82 num [0-9]+|[0-9]*"."[0-9]+
83 string {string1}|{string2}
84 badstring {badstring1}|{badstring2}
85 badcomment {badcomment1}|{badcomment2}
86 baduri {baduri1}|{baduri2}|{baduri3}
87 url ([!#$%&*-~]|{nonascii}|{escape})*
88 s [ \t\r\n\f]+
89 w {s}?
90 nl \n|\r\n|\r|\f
91
92 A a|\\0{0,4}(41|61)(\r\n|[ \t\r\n\f])?
93 C c|\\0{0,4}(43|63)(\r\n|[ \t\r\n\f])?
94 D d|\\0{0,4}(44|64)(\r\n|[ \t\r\n\f])?
95 E e|\\0{0,4}(45|65)(\r\n|[ \t\r\n\f])?
96 G g|\\0{0,4}(47|67)(\r\n|[ \t\r\n\f])?|\\g
97 H h|\\0{0,4}(48|68)(\r\n|[ \t\r\n\f])?|\\h
98 I i|\\0{0,4}(49|69)(\r\n|[ \t\r\n\f])?|\\i
99 K k|\\0{0,4}(4b|6b)(\r\n|[ \t\r\n\f])?|\\k
100 L l|\\0{0,4}(4c|6c)(\r\n|[ \t\r\n\f])?|\\l
101 M m|\\0{0,4}(4d|6d)(\r\n|[ \t\r\n\f])?|\\m
102 N n|\\0{0,4}(4e|6e)(\r\n|[ \t\r\n\f])?|\\n
103 O o|\\0{0,4}(4f|6f)(\r\n|[ \t\r\n\f])?|\\o
104 P p|\\0{0,4}(50|70)(\r\n|[ \t\r\n\f])?|\\p
105 R r|\\0{0,4}(52|72)(\r\n|[ \t\r\n\f])?|\\r
106 S s|\\0{0,4}(53|73)(\r\n|[ \t\r\n\f])?|\\s
107 T t|\\0{0,4}(54|74)(\r\n|[ \t\r\n\f])?|\\t
108 U u|\\0{0,4}(55|75)(\r\n|[ \t\r\n\f])?|\\u
109 X x|\\0{0,4}(58|78)(\r\n|[ \t\r\n\f])?|\\x
110 Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z
111
112 %%
113
114 {s} {return S;}
115
116 {comment} {return COMMENT;}
117 #\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
118 {badcomment} /* unclosed comment at EOF */
119
120 "<!--" {return CDO;}
121 "-->" {return CDC;}
122 "~=" {return INCLUDES;}
123 "|=" {return DASHMATCH;}
124
125 {string} {return STRING;}
126 {badstring} {return BAD_STRING;}
127
128 {ident} {return IDENT;}
129
130 "#"{name} {return HASH;}
131
132 @{I}{M}{P}{O}{R}{T} {return IMPORT_SYM;}
133 @{P}{A}{G}{E} {return PAGE_SYM;}
134 @{M}{E}{D}{I}{A} {return MEDIA_SYM;}
135 "@charset " {return CHARSET_SYM;}
136
137 "!"({w}|{comment})*{I}{M}{P}{O}{R}{T}{A}{N}{T} {return IMPORTANT_SYM;}
138
139 {num}{E}{M} {return EMS;}
140 {num}{E}{X} {return EXS;}
141 {num}{P}{X} {return LENGTH;}
142 {num}{C}{M} {return LENGTH;}
143 {num}{M}{M} {return LENGTH;}
144 {num}{I}{N} {return LENGTH;}
145 {num}{P}{T} {return LENGTH;}
146 {num}{P}{C} {return LENGTH;}
147 {num}{D}{E}{G} {return ANGLE;}
148 {num}{R}{A}{D} {return ANGLE;}
149 {num}{G}{R}{A}{D} {return ANGLE;}
150 {num}{M}{S} {return TIME;}
151 {num}{S} {return TIME;}
152 {num}{H}{Z} {return FREQ;}
153 {num}{K}{H}{Z} {return FREQ;}
154 {num}{ident} {return DIMENSION;}
155
156 {num}% {return PERCENTAGE;}
157 {num} {return NUMBER;}
158
159 "url("{w}{string}{w}")" {return URI;}
160 "url("{w}{url}{w}")" {return URI;}
161 {baduri} {return BAD_URI;}
162
163 {ident}"(" {return FUNCTION;}
164
165 . {return *yytext;}
166
167 %%