[antlr-interest] Serious Bug when using BitSet generation -
Forgot: USING ANTLR 2.7.5 !!!!
Geir Ove Skjaervik
geiroves at online.no
Thu Oct 6 17:56:38 PDT 2005
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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20051007/d9633b31/attachment-0001.html
More information about the antlr-interest
mailing list