Why am I getting an error when assigning tokens to a channel?

后端 未结 1 1025
慢半拍i
慢半拍i 2021-01-20 20:47

I have the following code in my .g4 file.

@lexer::members{
public static final int WHITESPACE = 1;
public static final int COMMENTS = 2;
}


WS :  (\' \'|\'\\         


        
相关标签:
1条回答
  • 2021-01-20 21:40

    You are not receiving an error; it is a warning. In particular, it is the UNKNOWN_LEXER_CONSTANT warning, which is new to ANTLR 4.2.

    Compiler Warning 155.

    rule 'rule' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output

    A lexer rule contains a standard lexer command, but the constant value argument for the command is an unrecognized string. As a result, the lexer command will be translated as a custom lexer action, preventing the command from executing in some interpreted modes. The output of the lexer interpreter may not match the output of the generated lexer.

    The following rule produces this warning.

    @members {
    public static final int CUSTOM = HIDDEN + 1;
    }
    
    X : 'foo' -> channel(HIDDEN);           // ok
    Y : 'bar' -> channel(CUSTOM);           // warning 155
    
    0 讨论(0)
提交回复
热议问题