I\'m trying to implement a expression handling grammar (that deals with nested parenthesis and stuff). I have the following so far, but they can\'t deal with some cases (suc
What's going on is that your Expression/Expressions support single parentheses but not multiple parentheses (as you concluded). I don't have ANTLR specific experience but I've worked with Javacc which shares many similar concepts (I wrote a grammar for Prolog... don't ask).
To handle nested parentheses, you typically have something similar to:
ParenthesisExpression: '(' (ParenthesisExpression | Expression) ')';
This would mean that the expression is either wrapped in parentheses or it's just a raw expression. As for how the AST deals with this, a ParenthesisExpression 'is a' Expression, so it can be represented as a subclass or an implementation of (if Expression is an interface/abstract class of sorts).