Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 96 lines (86 sloc) 3.469 kB
05eedb5 @itod initial add
authored
1 /**
2 A Grammar for CSS
3
4 This grammar is intentionally lenient/forgiving.
5 The purpose is to highlight, not validate (possibly invalid) CSS.
6
7 */
8
d0034af @itod Merge from SVN. All new Static features included
authored
9 @symbols = '//';
10 @singleLineComments = '//';
05eedb5 @itod initial add
authored
11 @multiLineComments = '/*' '*/';
d0034af @itod Merge from SVN. All new Static features included
authored
12 @wordState = '-' '@';
05eedb5 @itod initial add
authored
13
d0034af @itod Merge from SVN. All new Static features included
authored
14 @start
15 @before {
16 PKTokenizer *t = self.tokenizer;
17
18 // whitespace
19 // self.silentlyConsumesWhitespace = YES;
20 // t.whitespaceState.reportsWhitespaceTokens = YES;
21 // self.assembly.preservesWhitespaceTokens = YES;
22
23 // symbols
24 [t.symbolState add:@"/*"];
25 [t.symbolState add:@"*/"];
26 [t.symbolState add:@"//"];
27 [t.symbolState add:@"url("];
28 [t.symbolState add:@"URL("];
29
30 // word chars -moz, -webkit, @media, #id, .class, :hover
31 [t setTokenizerState:t.wordState from:'-' to:'-'];
32 [t setTokenizerState:t.wordState from:'@' to:'@'];
33 [t setTokenizerState:t.wordState from:'.' to:'.'];
34 [t setTokenizerState:t.wordState from:'#' to:'#'];
35 [t.wordState setWordChars:YES from:'-' to:'-'];
36 [t.wordState setWordChars:YES from:'@' to:'@'];
37 [t.wordState setWordChars:YES from:'.' to:'.'];
38 [t.wordState setWordChars:YES from:'#' to:'#'];
39 /* [t.wordState setFallbackState:t.symbolState from:'-' to:'-'];
40 [t.wordState setFallbackState:t.symbolState from:'@' to:'@'];
41 [t.wordState setFallbackState:t.symbolState from:'.' to:'.'];
42 [t.wordState setFallbackState:t.symbolState from:'#' to:'#'];
43 */
44 // comments
45 [t setTokenizerState:t.commentState from:'/' to:'/'];
46 [t.commentState setFallbackState:t.symbolState from:'/' to:'/'];
47 [t.commentState addSingleLineStartMarker:@"//"];
48 [t.commentState addMultiLineStartMarker:@"/*" endMarker:@"*/"];
49 t.commentState.reportsCommentTokens = YES;
50
51 // urls
52 [t setTokenizerState:t.delimitState from:'u' to:'u'];
53 [t setTokenizerState:t.delimitState from:'U' to:'U'];
54 [t.delimitState addStartMarker:@"url(" endMarker:@")" allowedCharacterSet:nil];
55 [t.delimitState addStartMarker:@"URL(" endMarker:@")" allowedCharacterSet:nil];
56 }
57 = ruleset*;
05eedb5 @itod initial add
authored
58 ruleset = selectors openCurly decls closeCurly;
59 selectors = selector commaSelector*;
d0034af @itod Merge from SVN. All new Static features included
authored
60 selector = (selectorWord | hashSym | dot | colon | gt | openBracket | closeBracket | eq | selectorQuotedString | tilde | pipe)+;
05eedb5 @itod initial add
authored
61 selectorWord = Word;
62 selectorQuotedString = QuotedString;
63 commaSelector = comma selector;
64 decls = Empty | actualDecls;
65 actualDecls = decl decl*;
d0034af @itod Merge from SVN. All new Static features included
authored
66 decl = property colon expr important? semi;
05eedb5 @itod initial add
authored
67 property = Word;
d0034af @itod Merge from SVN. All new Static features included
authored
68 expr = (string | constant | num | url | openParen | closeParen | comma | nonTerminatingSymbol)+;
69 url = urlLower | urlUpper;
70 urlLower = %{'url(', ')'};
71 urlUpper = %{'URL(', ')'};
72 nonTerminatingSymbol = {return NE(LS(1), @";") && NE(LS(1), @"!");}? fwdSlash | Symbol;
73 important = bang Word;
05eedb5 @itod initial add
authored
74 string = QuotedString;
75 constant = Word;
76
77 openCurly = '{';
78 closeCurly = '}';
79 openBracket = '[';
80 closeBracket = ']';
81 eq = '=';
82 comma = ',';
83 colon = ':';
84 semi = ';';
85 openParen = '(';
86 closeParen = ')';
87 gt = '>';
88 tilde = '~';
89 pipe = '|';
90 fwdSlash = '/';
d0034af @itod Merge from SVN. All new Static features included
authored
91 hashSym = '#';
05eedb5 @itod initial add
authored
92 dot = '.';
d0034af @itod Merge from SVN. All new Static features included
authored
93 at = '@';
94 bang = '!';
05eedb5 @itod initial add
authored
95
96 num = Number;
Something went wrong with that request. Please try again.