[antlr-interest] Serious Bug when using BitSet generation-Forgot: USING ANTLR 2.7.5 !!!!

Terence Parr parrt at cs.usfca.edu
Mon Oct 10 15:08:48 PDT 2005


Hi Geir,

I'm overwhelmed preparing for the ANTLR2005 workshop at the  
moment...sorry for my lack of responsiveness at the moment...perhaps  
you can ping me again in a couple of weeks.

Ter
On Oct 10, 2005, at 1:33 PM, Geir Ove Skjaervik wrote:

> Hello Terrence,
>
> When you have the time, can you please consider this problem ? It  
> looks like a bug to me as my code work when I do NOT use  
> Bitsets.However, I guess the if() code is more time consuming. I  
> also think it is important for everyone to know about this  
> scenario, and how to avoid it if possible.
>
>
> Geir Ove
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- 
> bounces at antlr.org] On Behalf Of Geir Ove Skjaervik
> Sent: 9. oktober 2005 23:37
> To: antlr-interest at antlr.org
> Subject: RE: [antlr-interest] Serious Bug when using BitSet  
> generation-Forgot: USING ANTLR 2.7.5 !!!!
>
> Hello,
>
> Really nobody have a comment on this? It looks like a bug to me,  
> and a serious one ! At least ANTLR behaves differently when using if 
> () code then Bitsets, and it is not supposed to do that, at least  
> now without issuing any warnings that the bitsets may behave  
> wronly, or what?
>
> Terrence ?
>
> Geir Ove
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- 
> bounces at antlr.org] On Behalf Of Geir Ove Skjaervik
> Sent: 7. oktober 2005 02:57
> To: antlr-interest at antlr.org
> Subject: RE: [antlr-interest] Serious Bug when using BitSet  
> generation -Forgot: USING ANTLR 2.7.5 !!!!
>
> Forgot: USING ANTLR 2.7.5 !!!!
>
> Geir Ove
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- 
> bounces at antlr.org] On Behalf Of Geir Ove Skjaervik
> Sent: 7. oktober 2005 02:44
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Serious Bug when using BitSet generation
>
> Hello,
>
> I seem to have encountered a serious bug when using bitset  
> generation (the default). I have had to turn it of setting   
> codeGenBitsetTestThreshold=999;
>
> The problem occurs in empty productions preceded by syntactic  
> predicates. I have this in several bocks as shown below. When using  
> bitset generation, I get NoViableAltException because of the wrong  
> code generation whenever a particular block should match an empty  
> production. Here is an excerpt of the code:
>
> (Terrence, If you need samples of the generated code with / without  
> BitSet generation, I will provide it. Right now I am very tired,  
> just wanted to post this!)
>
> ------------------------------------ Start Parser Code Excerpt  
> -------------------------------------------
>
> .....
>
> parseProgram returns [String r=null]
>  : c0:commonProgramHeader
>    c1:commonTitleDescriptionUsesStoresBlock1
>    c2:commonConstantsBlock2
>    c3:commonLibraryBlock3
>    c4:commonFormulaBlock4
>    c5:commonFunctionCallBlock5
>    end:RCURLY (SEMI!)? EOF!
>  ;
>
>
> commonProgramHeader
>  :  (autoGeneratedDateTag)?
>   (p:PROGRAM^<AST=no.oss.gos.FunctionNode> pId:ID {isProgram =  
> true;} | CATEGORY^ cId:ID {isCategory = true;} | CONSTANTS^ gId:ID  
> {isConstants = true;}) LCURLY
>  ;
>
>
> commonTitleDescriptionUsesStoresBlock1
>  {
>   String programTitle = null, programDescription = null;
>   int pos = 0; // rewind position set below
>  }
>  // We need to terminate the (title)? (description)?  
> (storesDeclarations)? (usesDeclarations)? construction
>  // or we get an ambiguity: Thus, we state that we expect  
> (CONSTANTS! | LIBRARY! | FORMULAS!) following this optional construct
>  // But then we need to rewind before continuing: Thus we use a mark 
> () and rewind() to do this !
>  : {isProgram | isCategory}? (programTitle=title)?  
> (programDescription=description)? (storesDeclarations)?  
> (usesDeclarations)? {pos=mark();} (CONSTANTS! | LIBRARY! | FORMULAS!)
>    {
>     rewind(pos);
>     options.setProgramDescription(programDescription);
>     options.setProgramTitle(programTitle);
>    }
>  | {isProgram}? ( )         ****************   NOTE : These kind of  
> empty productions FAIL to match an empty Production when using  
> BITSET generation !
>  | {isCategory}? ( )
>  | {isConstants}?   ( )
>  ;
>
> commonConstantsBlock2
>  : {isCategory}? constantDeclarations
>  | {isCategory}? ( )
>  | {isConstants}? constantDeclarationsList
>  | {isProgram}? ( )
>  ;
>
> commonLibraryBlock3
>  : {isCategory}? libraryDeclarations
>  | {isCategory}? ( )
>  | {isProgram}?  ( )
>  | {isConstants}? ( )
>  ;
>
> commonFormulaBlock4
>  : {isProgram}? formulaDeclarations
>  | {isCategory}? formulaDeclarations
>  | {isConstants}? ( )
>  ;
>
> commonFunctionCallBlock5
>  : {isProgram}? mainCall SEMI!
>  | {isCategory}? ( )
>  | {isConstants}? ( )
>  ;
>
> .........
>
>
> ------------------------------------ End Parser Code Excerpt  
> -------------------------------------------
>
>
> regards
>
> Geir Ove Skjaervik
> Objective Software Solutions
> Norway
> Phone: Int+907-48-869
> Fax: Int+47-6988-5947
> E-mail: objective.software at online.no
> WEB: http://objective.bitfikler.com/
>
>



More information about the antlr-interest mailing list