How to discriminate between different parsing alternatives in the visitor

31 views
Skip to first unread message

Amatus Wicker

unread,
Dec 1, 2023, 9:06:11 PM12/1/23
to antlr-discussion
If I have a grammar with different alternatives like this one:

statement: 'print' expr | 'let' ID '=' ID ;

How do I find out in the visitor which rule was applied? Is there a possibility to label rules?

Sorry if this is a stupid question, I am pretty new to ANTLR.
Many thanks in advance!

Amatus Wicker

unread,
Dec 1, 2023, 9:51:10 PM12/1/23
to antlr-discussion
Never mind, found how to do it (by adding #name tags to the rules).
Reply all
Reply to author
Forward
0 new messages