You might start with this one http://www.antlr.org/grammar/1240941192304/css21.g
(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). Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Michnay Balázs > Sent: Monday, January 18, 2010 6:18 AM > To: [email protected] > 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 > > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
