]> sjero.net Git - wget/blob - src/css.l
NEWS: cite --start-pos
[wget] / src / css.l
1 %option case-insensitive
2 %option noyywrap
3 %option never-interactive
4 %option nounput
5
6 %{
7 /* Lex source for CSS tokenizing.
8    Taken from http://www.w3.org/TR/CSS21/grammar.html#q2
9    Copyright (C) 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
10
11 This file is part of GNU Wget.
12
13 GNU Wget is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3 of the License, or (at
16 your option) any later version.
17
18 GNU Wget is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
25
26 Additional permission under GNU GPL version 3 section 7
27
28 If you modify this program, or any covered work, by linking or
29 combining it with the OpenSSL project's OpenSSL library (or a
30 modified version of that library), containing parts covered by the
31 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
32 grants you additional permission to convey the resulting work.
33 Corresponding Source for a non-source form of such a combination
34 shall include the source code for the parts of OpenSSL used as well
35 as that of the covered work.  */
36
37 #define YY_NO_INPUT
38
39 #include "css-tokens.h"
40
41 %}
42
43 h               [0-9a-f]
44 nonascii        [\200-\377]
45 unicode         \\{h}{1,6}(\r\n|[ \t\r\n\f])?
46 escape          {unicode}|\\[^\r\n\f0-9a-f]
47 nmstart         [_a-z]|{nonascii}|{escape}
48 nmchar          [_a-z0-9-]|{nonascii}|{escape}
49 string1         \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
50 string2         \'([^\n\r\f\\']|\\{nl}|{escape})*\'
51 invalid1        \"([^\n\r\f\\"]|\\{nl}|{escape})*
52 invalid2        \'([^\n\r\f\\']|\\{nl}|{escape})*
53
54 comment         \/\*[^*]*\*+([^/*][^*]*\*+)*\/
55 ident           -?{nmstart}{nmchar}*
56 name            {nmchar}+
57 num             [0-9]+|[0-9]*"."[0-9]+
58 string          {string1}|{string2}
59 invalid         {invalid1}|{invalid2}
60 url             ([!#$%&*-~]|{nonascii}|{escape})*
61 s               [ \t\r\n\f]
62 w               ({s}|{comment})*
63 nl              \n|\r\n|\r|\f
64
65 A               a|\\0{0,4}(41|61)(\r\n|[ \t\r\n\f])?
66 C               c|\\0{0,4}(43|63)(\r\n|[ \t\r\n\f])?
67 D               d|\\0{0,4}(44|64)(\r\n|[ \t\r\n\f])?
68 E               e|\\0{0,4}(45|65)(\r\n|[ \t\r\n\f])?
69 G               g|\\0{0,4}(47|67)(\r\n|[ \t\r\n\f])?|\\g
70 H               h|\\0{0,4}(48|68)(\r\n|[ \t\r\n\f])?|\\h
71 I               i|\\0{0,4}(49|69)(\r\n|[ \t\r\n\f])?|\\i
72 K               k|\\0{0,4}(4b|6b)(\r\n|[ \t\r\n\f])?|\\k
73 M               m|\\0{0,4}(4d|6d)(\r\n|[ \t\r\n\f])?|\\m
74 N               n|\\0{0,4}(4e|6e)(\r\n|[ \t\r\n\f])?|\\n
75 P               p|\\0{0,4}(50|70)(\r\n|[ \t\r\n\f])?|\\p
76 R               r|\\0{0,4}(52|72)(\r\n|[ \t\r\n\f])?|\\r
77 S               s|\\0{0,4}(53|73)(\r\n|[ \t\r\n\f])?|\\s
78 T               t|\\0{0,4}(54|74)(\r\n|[ \t\r\n\f])?|\\t
79 X               x|\\0{0,4}(58|78)(\r\n|[ \t\r\n\f])?|\\x
80 Z               z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z
81
82 %%
83
84 {s}                     {return S;}
85
86 \/\*[^*]*\*+([^/*][^*]*\*+)*\/          {return S;} /* ignore comments */
87
88 "<!--"          {return CDO;}
89 "-->"                   {return CDC;}
90 "~="                    {return INCLUDES;}
91 "|="                    {return DASHMATCH;}
92
93 {w}"{"                  {return LBRACE;}
94 {w}"+"                  {return PLUS;}
95 {w}">"                  {return GREATER;}
96 {w}","                  {return COMMA;}
97
98 {string}                {return STRING;}
99 {invalid}               {return INVALID; /* unclosed string */}
100
101 {ident}                 {return IDENT;}
102
103 "#"{name}               {return HASH;}
104
105 "@import"               {return IMPORT_SYM;}
106 "@page"                 {return PAGE_SYM;}
107 "@media"                {return MEDIA_SYM;}
108 "@charset "             {return CHARSET_SYM;}
109
110 "!"{w}"important"       {return IMPORTANT_SYM;}
111
112 {num}{E}{M}             {return EMS;}
113 {num}{E}{X}             {return EXS;}
114 {num}{P}{X}             {return LENGTH;}
115 {num}{C}{M}             {return LENGTH;}
116 {num}{M}{M}             {return LENGTH;}
117 {num}{I}{N}             {return LENGTH;}
118 {num}{P}{T}             {return LENGTH;}
119 {num}{P}{C}             {return LENGTH;}
120 {num}{D}{E}{G}          {return ANGLE;}
121 {num}{R}{A}{D}          {return ANGLE;}
122 {num}{G}{R}{A}{D}       {return ANGLE;}
123 {num}{M}{S}             {return TIME;}
124 {num}{S}                {return TIME;}
125 {num}{H}{Z}             {return FREQ;}
126 {num}{K}{H}{Z}          {return FREQ;}
127 {num}{ident}            {return DIMENSION;}
128
129 {num}%                  {return PERCENTAGE;}
130 {num}                   {return NUMBER;}
131
132 "url("{w}{string}{w}")" {return URI;}
133 "url("{w}{url}{w}")"    {return URI;}
134 {ident}"("              {return FUNCTION;}
135
136 .                       {return *yytext;}
137
138 %%