First off, your OTHER rule should contain OR not AND if you want to accept '$' 
or '{' when they are not part of '${'.  

Other than that, it should be possible to write this without resorting to an 
action (semantic predicate), which would allow visualizing in ANTLRworks and so 
on.

-- Graham

>I've tried that grammar but it doesn't works. If I enter an input that
>contains $ or { in enters in an infinite bucle:
>
>Grammar:
>----
>OTHER: (
>           {input.LA(1)!='$' && input.LA(2)!='{'}? .   
>       )+;
>       
>ID  :  ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
>    ;
>       
>line   : (OTHER
>         | expr )*;
>
>expr   : '${' ID '}';
>---
>
>I'm sure I'm missing some basic concept but have passed more than
>three or four years from my last antlr parser and I've to refresh my
>parsing abilities.
>Some one can orient me of how to solve that? or what I'm doing wrong?
>
>Can I do that in one parser or is better to use one parser to separate
>arbitrary content of expressions and then use another parser for the
>expressions?
>
>A lot of thanks in advance,
>
>
>-- 
>Joan Jesús Pujol Espinar
>http://www.joanpujol.cat
>http://lujop.deviantart.com
>
>List: http://www.antlr.org/mailman/listinfo/antlr-interest
>Unsubscribe: 
>http://www.antlr.org/mailman/options/antlr-interest/your-email-address


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