ANTLR Warning suppression workaround
On p.285 of the ANTLR book it implies that you cannot suppress warnings in ANTLR v3 like you could in v2.
However, it appears that a semantic predicate works nicely as a workaround:
// StringsThe generated code now contains LL(2) lookahead for no reason, and some redundant code. For example, code that originally read
SQ_STRING: '\''! ({true}? ESC_SEQ | ~'\'')* '\''!;
DQ_STRING: '"'! ({true}? ESC_SEQ | ~'"')* '"'!;
BQ_STRING: '`'! ({true}? ESC_SEQ | ~'`')* '`'!;
fragment ESC_SEQ: '\\' ~('\n'|'\r');
if ( (LA19_0 == '\"') )Now says
{
alt19 = 1;
}
if ( (LA19_0 == '\"') )However, its behavior appears to be the same.
{
int LA19_1 = input.LA(2);
if ( (true) )
{
alt19 = 1;
}
}
The compiler will emit some "unreachable code" warnings. In C# you can disable them like this:
grammar Expr;
options {
language=CSharp;
}
@lexer::members {
#pragma warning disable 0162
}
@parser::members {
#pragma warning disable 0162
}
0 Comments:
Post a Comment
<< Home