[antlr-interest] Nubie: How to approach multiple "required" subrules in any order

gary mazzaferro garym at oedata.com
Fri Nov 6 07:41:10 PST 2009


H,

I'm new to antlr and learning as I'm writing a parser to an ast tree. I'm
not sure how to approach this problem ( I think its simple) and was hoping
someone could help me out.

I have a input stream with a token followed by 3 other rules. Each of the 3
"rules" occurs only once for the parse to be correct, but they can arrive in
any order. If it fails, it should continue on the next characters after
token_big. How do I write the "big_rule" ?

big_rule : token_big  ( rule1 | rule2 | rule3 )  -> " also, what do I put
here ?"
                not right >>>  ^      ^        ^

rule1: token1 '=' STRING -> ^('=' token1 STRING);
rule2: token2 '=' STRING -> ^('=' token2 STRING);
rule3: token3 '=' STRING -> ^('=' token3 STRING);

cheers,
gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091106/c4d4ac3a/attachment.html 


More information about the antlr-interest mailing list