[antlr-interest] Paranoia, paranoia...

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Tue Aug 4 06:32:36 PDT 2009


Okay, I might just be being paranoid, but I wanted to sanity check 
something...

There's a rule "constraint" that matches LPAREN, a potentially unlimited 
number of other things (including nested constraints), then RPAREN. I 
wanted a rule that will match any number of these.

Any LPAREN after a constraint will be the start of another constraint.

So the rule I have is:

constraints : constraint ((LPAREN)=>constraint)* -> ^(CONSTRAINTS 
constraint+) ;

I believe this will match one or more constraints, and make a new 
subtree with each constraint a node under it (potentially being a 
subtree themselvs).

Does this do what I think it does?

NB: constraint+ doesn't work because it can't tell how far to look 
ahead. It has to finish matching one and then see if there's more.

-- 
Sam Barnett-Cormack


More information about the antlr-interest mailing list