[antlr-interest] Code generated for gated semantic predicates
Mike Lischke
mike at lischke-online.de
Thu Nov 8 05:16:09 PST 2012
Hi,
I have trouble with a simple rule that uses a gated semantic predicate, because of the generated code (antlr v3.4). Given these 3 simple rules:
string_literal:
NCHAR_TEXT
| UNDERSCORE_CHARSET? (single_quoted_string | {!SQL_MODE_ACTIVE(SQL_MODE_ANSI_QUOTES)}? => double_quoted_string)
;
single_quoted_string:
( options { greedy = true; }: SINGLE_QUOTED_TEXT)+
;
double_quoted_string:
( options { greedy = true; }: DOUBLE_QUOTED_TEXT)+
;
the code generated for double_quoted_string contains a check which makes no sense to me:
// MySQL.g:2537:2: ( DOUBLE_QUOTED_TEXT )+
{
int cnt823=0;
for (;;)
{
int alt823=2;
switch ( LA(1) )
{
case DOUBLE_QUOTED_TEXT:
{
{
/* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
*/
int LA823_67 = LA(2);
if ( (!( ((((SQL_MODE_ACTIVE(SQL_MODE_ANSI_QUOTES)))||((!SQL_MODE_ACTIVE(SQL_MODE_ANSI_QUOTES))))) )))
{
alt823=1;
}
}
}
break;
}
alt823 is never set because of the if () always evaluates to false and I have no idea how get rid of this check. It simply doesn't belong there since the parent rule (string_literal) already ran the predicate).
Any hint to solve this is welcome!
Mike
--
www.soft-gems.net
More information about the antlr-interest
mailing list