Reputation: 2712
I have the following assignment about extending an Antlr grammar.
What I've tried is:
I am not sure whether this is the correct solution or not. Can anyone guide me in the right direction?
Upvotes: 1
Views: 209
Reputation: 170148
2 problems here: 1) you have 2 the same alt-labels (# Lists
), and 2) you only allow zero or a single expression in your list. It should be this:
expr
: ...
| '(' expr ')' # Parenthesis
| '[' ( expr ( ',' expr )* )? ']' # Lists
;
Upvotes: 2