[antlr-interest] single-pass pattern matching "for free"?

Sohail Somani sohail at taggedtype.net
Sat Jan 14 20:09:51 PST 2006


On Sat, 2006-01-14 at 15:59 -0800, Terence Parr wrote:
> Perhaps we can have the ease of specification of Andy's solution  
> without having to handbuild a specific pattern engine...well, if  
> we're going to only do a single linear check for a match, apply rule,  
> and repeat.  Imagine a pattern engine like this:
> 
> <expr>+0 -> <expr>
> <expr>*0 -> 0
> 
> Can't we auto convert this to:
> 
> rules returns [String result]
>        :       => expr '+' INT {$INT.text.equals("0")}? {$result =  
> $expr.text;}
>        |       => expr '*' INT {$INT.text.equals("0")}? {$result =  
> $INT.text;}
>        ;

After some more thought, doesn't it seem like just a more concise way to
specify tree parsing? What would the differences be?



More information about the antlr-interest mailing list