[antlr-interest] Bug in ANTLR-3.1.2 with tree grammar wildcard list label x+= ?

Laurent Caillette laurent.caillette at gmail.com
Sat Feb 28 22:04:39 PST 2009


Hi Ter,

I've seen the Jira issue. It doesn't describe what I've found. My
grammar is OK with ANTLR-3.1.1 and it breaks with ANTLR-3.1.2. Sorry
if I was unclear the first time.

This should be reproduceable with following grammar Bug.g:

<<<<<<<<<<

grammar Bug ;

options { output = AST ; }

tokens {
  PART ;
}

part
  : (   p += levelIntroducer
      | p += cellRowSequence
    )
    EOF
    -> ^( PART $p+ )
  ;

levelIntroducer : 'L' ;
cellRowSequence : 'C' ;

>>>>>>>>>>

I try to start the debugger from ANTLRWorks-1.2.3. As it compiles the
Java code I get this:

[06:39:46] Checking Grammar...
[06:39:57] /Users/Laurent/Novelang/antlrworks/BugParser.java:142:
incompatible types
[06:39:57] found   : BugParser.levelIntroducer_return
[06:39:57] required: BugParser.cellRowSequence_return
[06:39:57]                     p=levelIntroducer();
[06:39:57]                                      ^
[06:39:57] Note: /Users/Laurent/Novelang/antlrworks/BugParser.java
uses unchecked or unsafe operations.
[06:39:57] Note: Recompile with -Xlint:unchecked for details.
[06:39:57] 1 error
[06:40:45] /Users/Laurent/Novelang/antlrworks/BugParser.java:142:
incompatible types
[06:40:45] found   : BugParser.levelIntroducer_return
[06:40:45] required: BugParser.cellRowSequence_return
[06:40:45]                     p=levelIntroducer();
[06:40:45]                                      ^
[06:40:45] Note: /Users/Laurent/Novelang/antlrworks/BugParser.java
uses unchecked or unsafe operations.
[06:40:45] Note: Recompile with -Xlint:unchecked for details.
[06:40:45] 1 error

I had a look at the Java code generated by ANTLR-3.1.1 where p seems
declared as RuleReturnScope. With ANTLR-3.1.2, p has the type of the
last rule (BugParser.cellRowSequence_return).


Thanks for all the hard work,

c.


On Sat, Feb 28, 2009 at 5:58 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> hi. should work if output=AST (I added a comment to existing request to be
> sure):
>
> http://www.antlr.org/jira/browse/ANTLR-381
>
> if not output=AST, it doesn't know what to put in list.  the internal return
> object? one of the return values?
>
> Ter
> On Feb 27, 2009, at 4:07 PM, Laurent Caillette wrote:
>
>>  (   p += levelIntroducer
>>     | p += paragraph
>>     | p += blockQuote
>>     | p += literal
>>     | p += bigDashedListItem
>>     | p += cellRowSequence
>>   )
>
>


More information about the antlr-interest mailing list