Skip to content

Commit 08f6933

Browse files
committed
added css grammar comments; tweaked newline handling
1 parent b71f739 commit 08f6933

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

parsers/CSSGrammar.pm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This should be doing css2.1; hopefully CSS3 when that's ready (but that may be a while)
1+
# This should be doing CSS2.1; hopefully CSS3 when that's ready (but that may be a while)
22

33
grammar CSSGrammar {
44
# builtin: ident (we use cssident), alpha
@@ -39,8 +39,7 @@ grammar CSSGrammar {
3939
token angle {:i <number> [ deg | rad | grad ] };
4040
token time {:i <number> [ ms | s ] };
4141
token freq {:i <number> k?hz };
42-
token string { ('"' | \') (<- [\n\r\f\\"]>|\\<nl>)* $0 };
43-
token nl { \n | \r\n | \r };
42+
token string { ('"' | \') (<- [\n]>|\\ \n)*? $0 };
4443
token uri { url '(' [ <string> | <url>] ')'};
4544
token url { ( <- [\( \) \' \" \\]> )* };
4645
token FUNCTION { <cssident> '(' };
@@ -55,5 +54,11 @@ grammar CSSGrammar {
5554

5655
rule page {:i'@page' [':'<cssident>]? <declarations> }
5756

57+
# Comments and whitespace.
58+
token comment {'<!--' .*? '-->' | '/*' .*? '*/'}
59+
# override <ws> builtin. Note: \n matches a logical (platform
60+
# independent) newline in Perl 6
61+
token ws { <!ww> [ \n | "\t" | " " | <comment> ]* }
62+
5863
method panic($e) {die $e;}
5964
}

0 commit comments

Comments
 (0)