[antlr-interest] Complex rules?

Michael Matera mike.matera at xilinx.com
Fri Feb 12 11:46:48 PST 2010


Hi Michael,

I have great news for you.  ANTLR does this for you.  Here's an example:

//
// Parser rules

statement: pos | neg ;

pos: ID 'is' ID ;

neg: 'not' ID ;

//
// Lexer rules

ID: ('A'..'Z' | 'a'..'z')+ ;

This example works because ANTLR tests tokens produced by ID against 
literal values used in the parser.  Try it out.

Cheers
./m

Michael Moore wrote:
> Hi guys,
> 
>  
> 
> This is probably a bit of a newbie question, but I'm trying to write a rule
> that basically says "match any 'foo' that also does not match any 'bar'"
> where 'foo' is a basic rule (matches all letters and numbers) and 'bar' is a
> list of keywords. Is there a way to produce this kind of logic in ANTLR or
> does the logic need to be approached from a different direction to solve
> this one?
> 
>  
> 
> Thanks,
> 
> Mike
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.




More information about the antlr-interest mailing list