summaryrefslogtreecommitdiff
path: root/css/scanner.l
blob: 9849665b4ad32165c99114b3824ce7e118c5a503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 * $Id: scanner.l,v 1.2 2003/04/01 21:33:08 bursa Exp $
 */

%{
#include "parser.h"
%}

%option 8bit
%option batch
%option case-insensitive
%option header-file="scanner.h"
%option outfile="scanner.c"
%option prefix="css_"
%option reentrant
%option never-interactive
%option noyywrap

/* see CSS2 Specification, chapter 4
   http://www.w3.org/TR/REC-CSS2/syndata.html,
   and errata
   http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata */

ident		{nmstart}{nmchar}*
name		{nmchar}+
nmstart		[a-zA-Z_]|{nonascii}|{escape}
nonascii	[\200-\377]
unicode		\\[0-9a-f]{1,6}[ \n\r\t\f]?
escape		{unicode}|\\[ -~\200-\377]
nmchar		[-a-zA-Z0-9_]|{nonascii}|{escape}
num		[+-]?[0-9]+|[0-9]*\.[0-9]+
string		{string1}|{string2}
string1		\"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
string2		\'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
nl		\n|\r\n|\r|\f
w		[ \t\r\n\f]*

%%

{ident}		{ return IDENT; }
@{ident}	{ return ATKEYWORD; }
{string}	{ return STRING; }
#{name}		{ return HASH; }
{num}		{ return NUMBER; }
{num}%		{ return PERCENTAGE; }
{num}{ident}	{ return DIMENSION; }
url\({w}{string}{w}\)|url\({w}([!#$%&*-~]|{nonascii}|{escape})*{w}\)	{
		  return URI; }
U\+[0-9A-F?]{1,6}(-[0-9A-F]{1,6})?	{
		  return UNICODE_RANGE; }
"<!--"		/* ignore CDO */
"-->"		/* ignore CDC */
;		{ return SEMI; }
\{		{ return LBRACE; }
\}		{ return RBRACE; }
\(		{ return LPAREN; }
\)		{ return RPAREN; }
\[		{ return LBRAC; }
\]		{ return RBRAC; }
[ \t\r\n\f]+	/* ignore whitespace */
\/\*[^*]*\*+([^/][^*]*\*+)*\/	/* ignore comments */
{ident}\(	{ return FUNCTION; }
~=		{ return INCLUDES; }
"|="		{ return DASHMATCH; }
:		{ return COLON; }
,		{ return COMMA; }
"+"		{ return PLUS; }
>		{ return GT; }
"."		{ return DOT; }
.		{ return DELIM; }

%%