[antlr-interest] Rule ignored in CSS grammar

Jim Idle jimi at temporal-wave.com
Mon Jan 18 09:01:45 PST 2010

You might start with this one 


(CSS 2.1 grammar that I contributed) and just upgrade it to CSS 3, which is not much different to be honest. The main difficulties are properly lexing the input and the example you quote does not do the lexing correctly. Adding to the parsing constructs is trivial.

I am not sure why you would try to prevent the use of '_' as that is part of the spec. However the way you are doing it will not work anyway because the lexer is context free and just produces the tokens it sees (it is not driven by the parser). 


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Michnay Balázs
> Sent: Monday, January 18, 2010 6:18 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Rule ignored in CSS grammar
> Hi Guys,
> The attached grammar is supposed to parse CSS files. I used this as an
> initial version:
> http://www.antlr.org/grammar/1214945003224/csst3.g
> First I tried to add a functionality to prevent "_" chars for property
> names, so I created a new lexer rule "CSSPROPERTYNAME" to ensure this.
> The "declaration" rule has been updated accordingly. The funny thing is
> that now the "selector" rule fails to recognize tag selectors like:
> .class_selector img {
>   property: value;
>   ...
> }
> Since my update should only affect property names and not selectors, I
> really do not understand what the problem is. I tried to define lexer
> rules as both fragments and literal values, no luck.
> I used ANTLRWorks to debug this and have noticed that in the "selector"
> rule "selectorOperation" is ignored:
> selector
>   : elem selectorOperation* attrib* pseudo? ->  elem selectorOperation*
> attrib* pseudo*
>   ;
> Any ideas?
> Thanks.
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.725 / Virus Database: 270.14.148/2629 - Release Date:
> 01/17/10 11:35:00

More information about the antlr-interest mailing list