-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
My parser contains the following characters:
WS : (' '|'\r'|'\t'|'\u000C'|'\n') -> skip;
SQ : ['];
DQ : '\u0022';
SP : '\u0020';
HTAB : '\u0009';
CR : '\u000D';
LF : '\u000A';
When I target C# the code is good and compiles fine, no errors in C# or Antlr.
But when I compile it against Java, I get:
error: unclosed character literal "'false'", "'null'", null, null, "'\u0022'", "'\u0020'", "'\u0009'",
When I look in the generated Java file I see:
private static String[] makeLiteralNames() {
return new String[] {
null, null, null, "'datetimeoffset'", "'datetime'", "'guid'", "'true'",
"'false'", "'null'", null, null, "'\u0022'", "'\u0020'", "'\u0009'",
"'\u000D'", "'\u000A'", null, null, null, "'$'", null, null, null, null,
"'('", "')'", "'['", "']'", "'{'", "'}'", "'~'", null, null, "'/'", "'.'",
"':'", "'%'", "'@'", "'!'", "'?'", "'_'", null, null, null, null, null,
null, "'asc'", "'desc'", "'and'", "'or'", "'eq'", "'ne'", "'lt'", "'le'",
"'gt'", "'ge'", "'in'", "'nin'", "'nlike'", "'like'"
};
}
The issue is that "'\u0022'"
is not valid Java, this should be '\u0022'.
Now this can be mitigated by changing the grammer to:
WS : (' '|'\r'|'\t'|'\u000C'|'\n') -> skip;
SQ : ['];
DQ : [\u0022];
SP : [\u0020];
HTAB : [\u0009];
CR : [\u000D];
LF : [\u000A];
But is this the recommended approach or a bug?