all labels or none

20 views
Skip to first unread message

Peter Cheung

unread,
Mar 3, 2018, 3:38:36 PM3/3/18
to antlr-discussion
Hi All
   Why we can only label all rules or none? Why antlr design like this?
Thanks
From Peter

Mike Lischke

unread,
Mar 4, 2018, 3:56:06 AM3/4/18
to antlr-di...@googlegroups.com
> Why we can only label all rules or none? Why antlr design like this?

Where did you see a rule like that? Rules cannot be labelled. Your question makes no sense.

However, when you ask why either all or none of top level alts in a rule must be labelled, the answer is this:

Because by labelling an alternative in a rule ANTLR4 replaces the overall rule context by a specific context for that alt. Hence, the original context is no longer available (it would be kinda semi-duplicate of the alt context). And if there's no rule context anymore, you need contexts for all other alts as well, which means, they also must be labelled.

Mike
--
www.soft-gems.net

Peter Cheung

unread,
Mar 5, 2018, 2:21:53 PM3/5/18
to antlr-discussion
Thanks Mike, forgive my bad english

Mike Lischke於 2018年3月4日星期日 UTC+8下午4時56分06秒寫道:
Reply all
Reply to author
Forward
0 new messages