On 02/25/2011 02:42 PM, Aurélien Baudet wrote:
>    Hello,
> 
> I'm currently writing an xtext plugin for css. I have a problem and I don't
> find any solution. My grammar works quite well for many css files but it
> fails on that:

> The grammar:
> 
> grammar css;

> elem:
>       IDENT
>       | '#' IDENT
>       | '.' IDENT;

>  COLOR:
>       '#' ('0'..'9' | 'a'..'f' | 'A'..'F')+;

Those are the 2 rules rules in conflict.  You need to find a way to
disambiguate the use of the # as a token.  It would help you to go back
to the general advice of not using quoted tokens in your parser.
Instead, have LEXER rules for each one.  You will probably need to merge
the COLOR and HASH rules together using a syntactic predicate in the
lexer rules.  Something like:

fragment
COLOR: ;

HASH: '#' ('0'..'9' | 'a'..'f' | 'A'..'F')=> (('0'..'9' | 'a'..'f' |
'A'..'F')+ { $type=COLOR; });

-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

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.

Reply via email to