At 21:12 16/03/2010, Brian Catlin wrote:
 >I don't get the errors I was getting before, but that is because 

 >the FILE_NAME token is matching everything,  I put a simple
 >printf action on the FILE_NAME token, and it gets called for
 >all input:
[...]
 >Is there a way to make the FILE_NAME token context sensitive so
 >that the lexer doesn't try to match it unless we're in a rule
 >that wants to find a file name?

No, ANTLR lexer's are context-free: you can't influence token 
selection from the parser.

What you need to do is to change your approach.  Have one token 
for QUOTED_STRING and another token for NAME.  Then, at the parser 
level (where you have context), decide whether any particular NAME 
is a command name or a filename (or whatever).


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