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

Jeffrey Guenther

I have the following code in my .g4 file.

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


WS :  (' '|'\t'|'\f')+ -> channel(WHITESPACE)
   ;

COMMENT 
    :   '//' ~('\n'|'\r')* -> channel(COMMENTS)
    ;

LINE_COMMENT 
    :   '/*' .*? '*/' NEWLINE? -> channel(WHITESPACE)
    ;

I'm getting the following errors:

warning(155): Shiro.g4:239:34: rule 'WS' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output

warning(155): Shiro.g4:243:38: rule 'COMMENT' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output

warning(155): Shiro.g4:247:42: rule 'LINE_COMMENT' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output

This is the technique described by Terrence in the ANTLR4 book to put tokens on separate channels. Why am I getting these warnings? Should I be concerned?

Sam Harwell

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why am I getting an error assigning a regex string to a variable?

From Dev

Why am I getting an error when I populating a custom listview?

From Dev

Why am I getting the error "Incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'." while sorting keys?

From Dev

Why am I getting the error "Incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'." while sorting keys?

From Dev

Why am I getting an AssertionError when assigning Arrays.asList() to var directly?

From Dev

Why am I getting this error

From Dev

Why am I getting an opencv error with size of images when they are as expected?

From Dev

Why am I getting a 500 internal error when updating indexableText?

From Dev

Why am I getting an error when calling a webservice function?

From Dev

Why am I getting an error in Prolog when trying out conc?

From Dev

Why am I getting a NoSuchBucket 404 error when forwarding www?

From Dev

Why am I getting an error when trying to append HTML in AngularJS?

From Dev

Why am I getting the following error when compiling this assembly?

From Dev

Why Am I Getting A Type Error When Running This Function?

From Dev

Why am I getting an error when creating Spring Beans in JHipster?

From Dev

Why am I getting this error message when searching for a library?

From Dev

Why I am getting $parse error when use it on object with array?

From Dev

why am I getting an error when trying to generate rsa 128

From Dev

Why am I getting an error when I try to print the contents of a file I am searching for?

From Dev

Why is below program giving me error when I am assigning true or false to a vector of type bool?

From Dev

why am i getting http error code 500 when i am sending a rest request

From Dev

why am I getting Exec format error when I am writing my linux service?

From Dev

Why am I getting this error message when I am using NSTimer to run function every x seconds?

From Dev

Why am I getting an error when I am trying to insert a while loop?

From Dev

Why am I only getting one take! from this channel?

From Dev

Why am I not getting Cross domain error?

From Dev

Why am i getting this template compile error?

From Dev

Why am I getting a 422 error code?

From Dev

why I am getting this error "undefined is not a function "

Related Related

  1. 1

    Why am I getting an error assigning a regex string to a variable?

  2. 2

    Why am I getting an error when I populating a custom listview?

  3. 3

    Why am I getting the error "Incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'." while sorting keys?

  4. 4

    Why am I getting the error "Incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'." while sorting keys?

  5. 5

    Why am I getting an AssertionError when assigning Arrays.asList() to var directly?

  6. 6

    Why am I getting this error

  7. 7

    Why am I getting an opencv error with size of images when they are as expected?

  8. 8

    Why am I getting a 500 internal error when updating indexableText?

  9. 9

    Why am I getting an error when calling a webservice function?

  10. 10

    Why am I getting an error in Prolog when trying out conc?

  11. 11

    Why am I getting a NoSuchBucket 404 error when forwarding www?

  12. 12

    Why am I getting an error when trying to append HTML in AngularJS?

  13. 13

    Why am I getting the following error when compiling this assembly?

  14. 14

    Why Am I Getting A Type Error When Running This Function?

  15. 15

    Why am I getting an error when creating Spring Beans in JHipster?

  16. 16

    Why am I getting this error message when searching for a library?

  17. 17

    Why I am getting $parse error when use it on object with array?

  18. 18

    why am I getting an error when trying to generate rsa 128

  19. 19

    Why am I getting an error when I try to print the contents of a file I am searching for?

  20. 20

    Why is below program giving me error when I am assigning true or false to a vector of type bool?

  21. 21

    why am i getting http error code 500 when i am sending a rest request

  22. 22

    why am I getting Exec format error when I am writing my linux service?

  23. 23

    Why am I getting this error message when I am using NSTimer to run function every x seconds?

  24. 24

    Why am I getting an error when I am trying to insert a while loop?

  25. 25

    Why am I only getting one take! from this channel?

  26. 26

    Why am I not getting Cross domain error?

  27. 27

    Why am i getting this template compile error?

  28. 28

    Why am I getting a 422 error code?

  29. 29

    why I am getting this error "undefined is not a function "

HotTag

Archive