Nested expression, how should I get the value

11 views
Skip to first unread message

Aaron Lewis

unread,
Mar 10, 2015, 5:52:24 AM3/10/15
to antlr-di...@googlegroups.com

I'm trying to parse things like this:

where length matches "5000" (status matches "200" OR status matches "302")

where
    : WHERE whereExpression
    ;

whereExpression
    : Identifier MATCHES StringLiteral
    | LPAREN whereExpression RPAREN
    | whereExpression AND whereExpression
    | whereExpression OR  whereExpression
    ;
WHERE: 'where' ;

Now if I need to get the value of Identifier and StringLiteral I could just use the $ stuff.

But how can I get the value from the whereExpression AND whereExpression pattern?

I've been thinking about replacing it with Identifier MATCHES StringLiteral AND Identifier MATCHES StringLiteral

But in that case I would have two variables with the same name.

What's the right solution?


Reply all
Reply to author
Forward
0 new messages