简体   繁体   中英

Meaning of Antlr4's LABEL_CONFLICTS_WITH_RULE

I have a rule as

nls
    :   NL*
    ;

with lexer token

// Inside (...) and [...] but not {...}, ignore newlines.
NL  : '\r'? '\n'            { this.ignoreTokenInsideParens(); }
    ;

on compile, i get

antlr:
 [java] error(69): Pel.g4:19:86: label nls conflicts with rule with same name

My understanding is that labels are #names you give to alternative branches of a production. I have no such labels.

So, what does this error mean?

Thanks to @BartKiers i looked at every nls use, and found i had an errant = sign where i had removed a variable assign in a rule, but missed the =, like

expression nls AND nls =expression

that was the issue.

It seems that you have a rule called nls , but also a label with that name:

nls
    :   NL*
    ;

...

rule
    : FOO BAR # nls
    ;

The # nls (or #nls ) is the label.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM