[antlr-interest] java 1.5 grammar strange beahviour

robermann robermann at gmail.com
Fri Jun 22 15:23:47 PDT 2007


Hi all
I have a strange error with java5 grammar. If I turn on rewrite mode
(options {k=2; backtrack=true; memoize=true; output=template;
rewrite=true;}), the following rule works:

    | 'break' Identifier? ';'      -> template(c={$text}) "
System.out.println(\"BREAK123\"); <c>"

whereas the following one:
    | 'break' Identifier? ';'      -> template(c={$text}) "
System.out.println(\"BREAK1234\"); <c>"

provokes the following incredibile message:

linux:~/java-antlr # java org.antlr.Tool JavaRewrite.g
ANTLR Parser Generator  Version 3.0 (May 17, 2007)  1989-2007
warning(200): JavaRewrite.g:779:9: Decision can match input such as
"'0'..'9'{'E', 'e'}{'+', '-'}'0'..'9'{'D', 'F', 'd', 'f'}" using multiple
alternatives: 3, 4
As a result, alternative(s) 4 were disabled for that input
warning(205): JavaRewrite.g:1:10: ANTLR could not analyze this decision in
rule Tokens; often this is because of recursive rule references visible from
the left edge of alternatives.  ANTLR will re-analyze the decision with a
fixed lookahead of k=1.  Consider using "options {k=1;}" for that decision
and possibly adding a syntactic predicate.
warning(209): JavaRewrite.g:821:1: Multiple token rules can match input such
as "'r'": T83, Identifier
As a result, tokens(s) Identifier were disabled for that input
warning(209): JavaRewrite.g:86:1: Multiple token rules can match input such
as "'+'": T89, T104, T108
As a result, tokens(s) T108,T104 were disabled for that input
warning(209): JavaRewrite.g:82:1: Multiple token rules can match input such
as "'^'": T95, T100
As a result, tokens(s) T100 were disabled for that input
warning(209): JavaRewrite.g:821:1: Multiple token rules can match input such
as "'w'": T78, Identifier
As a result, tokens(s) Identifier were disabled for that input
warning(209): JavaRewrite.g:34:1: Multiple token rules can match input such
as "'t'": T43, T52, T69, T80, T84, T112, Identifier
As a result, tokens(s) Identifier,T84,T80,T112,T69,T52 were disabled for
that input
warning(209): JavaRewrite.g:73:1: Multiple token rules can match input such
as "'*'": T29, T91
As a result, tokens(s) T91 were disabled for that input
warning(209): JavaRewrite.g:35:1: Multiple token rules can match input such
as "'v'": T40, T53, Identifier
As a result, tokens(s) Identifier,T53 were disabled for that input
warning(209): JavaRewrite.g:33:1: Multiple token rules can match input such
as "'s'": T27, T51, T54, T58, T64, T82, Identifier
As a result, tokens(s) Identifier,T64,T58,T54,T82,T51 were disabled for that
input
warning(209): JavaRewrite.g:770:1: Multiple token rules can match input such
as "'0'": HexLiteral, DecimalLiteral, OctalLiteral, FloatingPointLiteral
As a result, tokens(s) DecimalLiteral,FloatingPointLiteral,OctalLiteral were
disabled for that input
warning(209): JavaRewrite.g:778:1: Multiple token rules can match input such
as "'1'..'9'": DecimalLiteral, FloatingPointLiteral
As a result, tokens(s) FloatingPointLiteral were disabled for that input
warning(209): JavaRewrite.g:821:1: Multiple token rules can match input such
as "'l'": T60, Identifier
As a result, tokens(s) Identifier were disabled for that input
warning(209): JavaRewrite.g:818:1: Multiple token rules can match input such
as "'e'": T31, T76, ENUM, Identifier
As a result, tokens(s) Identifier,T76,ENUM were disabled for that input
warning(209): JavaRewrite.g:871:1: Multiple token rules can match input such
as "'/'": T92, T106, COMMENT, LINE_COMMENT
As a result, tokens(s) T106,COMMENT,LINE_COMMENT were disabled for that
input
warning(209): JavaRewrite.g:52:1: Multiple token rules can match input such
as "'f'": T49, T61, T70, T77, T81, Identifier
As a result, tokens(s) Identifier,T61,T81,T77,T70 were disabled for that
input
warning(209): JavaRewrite.g:49:1: Multiple token rules can match input such
as "'.'": T28, T67, FloatingPointLiteral
As a result, tokens(s) FloatingPointLiteral,T67 were disabled for that input
warning(209): JavaRewrite.g:61:1: Multiple token rules can match input such
as "'d'": T62, T72, T79, Identifier
As a result, tokens(s) Identifier,T72,T79 were disabled for that input
warning(209): JavaRewrite.g:28:1: Multiple token rules can match input such
as "'p'": T24, T45, T46, T47, Identifier
As a result, tokens(s) Identifier,T47,T45,T46 were disabled for that input
warning(209): JavaRewrite.g:67:1: Multiple token rules can match input such
as "'b'": T55, T57, T85, Identifier
As a result, tokens(s) Identifier,T57,T85 were disabled for that input
warning(209): JavaRewrite.g:87:1: Multiple token rules can match input such
as "'-'": T90, T105, T109
As a result, tokens(s) T109,T105 were disabled for that input
warning(209): JavaRewrite.g:80:1: Multiple token rules can match input such
as "'&'": T36, T93, T98
As a result, tokens(s) T93,T98 were disabled for that input
warning(209): JavaRewrite.g:79:1: Multiple token rules can match input such
as "'|'": T94, T97, T99
As a result, tokens(s) T99,T97 were disabled for that input
warning(209): JavaRewrite.g:89:1: Multiple token rules can match input such
as "'%'": T96, T107
As a result, tokens(s) T107 were disabled for that input
warning(209): JavaRewrite.g:83:1: Multiple token rules can match input such
as "'='": T44, T101
As a result, tokens(s) T101 were disabled for that input
warning(209): JavaRewrite.g:55:1: Multiple token rules can match input such
as "'a'": T48, T73, Identifier
As a result, tokens(s) Identifier,T73 were disabled for that input
warning(209): JavaRewrite.g:93:1: Multiple token rules can match input such
as "'!'": T102, T111
As a result, tokens(s) T111 were disabled for that input
warning(209): JavaRewrite.g:50:1: Multiple token rules can match input such
as "'n'": T50, T68, T113, Identifier
As a result, tokens(s) Identifier,T113,T68 were disabled for that input
warning(209): JavaRewrite.g:14:1: Multiple token rules can match input such
as "'i'": T26, T32, T39, T59, T75, T103, Identifier
As a result, tokens(s) T103,Identifier,T59,T75,T39,T32 were disabled for
that input
warning(209): JavaRewrite.g:69:1: Multiple token rules can match input such
as "'c'": T30, T56, T86, T87, T88, Identifier
As a result, tokens(s) Identifier,T86,T56,T88,T87 were disabled for that
input
warning(208): JavaRewrite.g:871:1: The following token definitions are
unreachable:
T32,T39,T45,T46,T47,T51,T52,T53,T54,T56,T57,T58,T59,T61,T64,T67,T68,T69,T70,T72,T73,T75,T76,T77,T79,T80,T81,T82,T84,T85,T86,T87,T88,T91,T93,T97,T98,T99,T100,T101,T103,T104,T105,T106,T107,T108,T109,T111,T112,T113,OctalLiteral,FloatingPointLiteral,ENUM,COMMENT,LINE_COMMENT


Having a template message a char longer is really an issue?? I cannot guess
what I'm missing...

Best regards
Roberto Mannai

-- 
Are you tired of making software? Play it! (http://www.codesounding.org)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070623/2f7a3c99/attachment-0001.html 


More information about the antlr-interest mailing list