]> sjero.net Git - wget/blob - src/css.l
mass change: update copyright years.
[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 "wget.h"
40 #include "css-tokens.h"
41
42 %}
43
44 h               [0-9a-f]
45 nonascii        [\200-\377]
46 unicode         \\{h}{1,6}(\r\n|[ \t\r\n\f])?
47 escape          {unicode}|\\[^\r\n\f0-9a-f]
48 nmstart         [_a-z]|{nonascii}|{escape}
49 nmchar          [_a-z0-9-]|{nonascii}|{escape}
50 string1         \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
51 string2         \'([^\n\r\f\\']|\\{nl}|{escape})*\'
52 invalid1        \"([^\n\r\f\\"]|\\{nl}|{escape})*
53 invalid2        \'([^\n\r\f\\']|\\{nl}|{escape})*
54
55 comment         \/\*[^*]*\*+([^/*][^*]*\*+)*\/
56 ident           -?{nmstart}{nmchar}*
57 name            {nmchar}+
58 num             [0-9]+|[0-9]*"."[0-9]+
59 string          {string1}|{string2}
60 invalid         {invalid1}|{invalid2}
61 url             ([!#$%&*-~]|{nonascii}|{escape})*
62 s               [ \t\r\n\f]
63 w               ({s}|{comment})*
64 nl              \n|\r\n|\r|\f
65
66 A               a|\\0{0,4}(41|61)(\r\n|[ \t\r\n\f])?
67 C               c|\\0{0,4}(43|63)(\r\n|[ \t\r\n\f])?
68 D               d|\\0{0,4}(44|64)(\r\n|[ \t\r\n\f])?
69 E               e|\\0{0,4}(45|65)(\r\n|[ \t\r\n\f])?
70 G               g|\\0{0,4}(47|67)(\r\n|[ \t\r\n\f])?|\\g
71 H               h|\\0{0,4}(48|68)(\r\n|[ \t\r\n\f])?|\\h
72 I               i|\\0{0,4}(49|69)(\r\n|[ \t\r\n\f])?|\\i
73 K               k|\\0{0,4}(4b|6b)(\r\n|[ \t\r\n\f])?|\\k
74 M               m|\\0{0,4}(4d|6d)(\r\n|[ \t\r\n\f])?|\\m
75 N               n|\\0{0,4}(4e|6e)(\r\n|[ \t\r\n\f])?|\\n
76 P               p|\\0{0,4}(50|70)(\r\n|[ \t\r\n\f])?|\\p
77 R               r|\\0{0,4}(52|72)(\r\n|[ \t\r\n\f])?|\\r
78 S               s|\\0{0,4}(53|73)(\r\n|[ \t\r\n\f])?|\\s
79 T               t|\\0{0,4}(54|74)(\r\n|[ \t\r\n\f])?|\\t
80 X               x|\\0{0,4}(58|78)(\r\n|[ \t\r\n\f])?|\\x
81 Z               z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z
82
83 %%
84
85 {s}                     {return S;}
86
87 \/\*[^*]*\*+([^/*][^*]*\*+)*\/          {return S;} /* ignore comments */
88
89 "<!--"          {return CDO;}
90 "-->"                   {return CDC;}
91 "~="                    {return INCLUDES;}
92 "|="                    {return DASHMATCH;}
93
94 {w}"{"                  {return LBRACE;}
95 {w}"+"                  {return PLUS;}
96 {w}">"                  {return GREATER;}
97 {w}","                  {return COMMA;}
98
99 {string}                {return STRING;}
100 {invalid}               {return INVALID; /* unclosed string */}
101
102 {ident}                 {return IDENT;}
103
104 "#"{name}               {return HASH;}
105
106 "@import"               {return IMPORT_SYM;}
107 "@page"                 {return PAGE_SYM;}
108 "@media"                {return MEDIA_SYM;}
109 "@charset "             {return CHARSET_SYM;}
110
111 "!"{w}"important"       {return IMPORTANT_SYM;}
112
113 {num}{E}{M}             {return EMS;}
114 {num}{E}{X}             {return EXS;}
115 {num}{P}{X}             {return LENGTH;}
116 {num}{C}{M}             {return LENGTH;}
117 {num}{M}{M}             {return LENGTH;}
118 {num}{I}{N}             {return LENGTH;}
119 {num}{P}{T}             {return LENGTH;}
120 {num}{P}{C}             {return LENGTH;}
121 {num}{D}{E}{G}          {return ANGLE;}
122 {num}{R}{A}{D}          {return ANGLE;}
123 {num}{G}{R}{A}{D}       {return ANGLE;}
124 {num}{M}{S}             {return TIME;}
125 {num}{S}                {return TIME;}
126 {num}{H}{Z}             {return FREQ;}
127 {num}{K}{H}{Z}          {return FREQ;}
128 {num}{ident}            {return DIMENSION;}
129
130 {num}%                  {return PERCENTAGE;}
131 {num}                   {return NUMBER;}
132
133 "url("{w}{string}{w}")" {return URI;}
134 "url("{w}{url}{w}")"    {return URI;}
135 {ident}"("              {return FUNCTION;}
136
137 .                       {return *yytext;}
138
139 %%