[antlr-interest] some problem with GnuCParser::attribute()

yan ywangxd at gmail.com
Sun Sep 24 01:30:31 PDT 2006


Dear everybody:

     I am a graduate student in xidian university of China. Our research
group is doing some research on Evolutionary Testing ( ET). Static analysis
is used to guide the dynamic search in ET.  For static analysis, The ANTLR
tool is used to product lexical analyzer, parser and tree parser. For some
reason, we need the lexical analyzer, parser and tree parser written in C++.
For Monty Zukowski has provided GNU C grammatical descriptions containing
Java actions. For convenience, I rewrite the actions and some relating
classes in C++. But when I use the ANTLR to produce the lexical analyzer,
parser and tree parser, there is some problem. I can't figure out the
reason. 

So I turn to you!  I will be very graceful if you can give me some
suggestions about the error!  I use antlr-2.7.6. 

The following is the mistake!

void GnuCParser::attribute() {

      returnAST = RefTNode(ANTLR_USE_NAMESPACE(antlr)nullAST);

      ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;

      RefTNode attribute_AST = RefTNode(ANTLR_USE_NAMESPACE(antlr)nullAST);

      

      try {      // for error handling

           { // ( ... )*

           for (;;) {

                 if ((_tokenSet_57.member(LA(1)))) {

                      {

                      RefTNode tmp99_AST =
RefTNode(ANTLR_USE_NAMESPACE(antlr)nullAST);

                      if ( inputState->guessing == 0 ) {

 

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////

//////////////////////////////There is a
error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//////////////////////////////LT(1) shouldn't be converted to RefAST but
RefTNode!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!

                            tmp99_AST =
RefTNode(astFactory->create(ANTLR_USE_NAMESPACE(antlr)RefAST(LT(1))));

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////

                            astFactory->addASTChild(currentAST,
ANTLR_USE_NAMESPACE(antlr)RefAST(tmp99_AST));

                      }

                      match(_tokenSet_57);

                      }

                 }

                 else if ((LA(1) == LPAREN)) {

                      RefTNode tmp100_AST =
RefTNode(ANTLR_USE_NAMESPACE(antlr)nullAST);

                      if ( inputState->guessing == 0 ) {

                            tmp100_AST = astFactory->create(LT(1));

                            astFactory->addASTChild(currentAST,
ANTLR_USE_NAMESPACE(antlr)RefAST(tmp100_AST));

                      }

                      match(LPAREN);

                      attributeList();

                      if (inputState->guessing==0) {

                            astFactory->addASTChild(currentAST,
ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));

                      }

                      RefTNode tmp101_AST =
RefTNode(ANTLR_USE_NAMESPACE(antlr)nullAST);

                      if ( inputState->guessing == 0 ) {

                            tmp101_AST = astFactory->create(LT(1));

                            astFactory->addASTChild(currentAST,
ANTLR_USE_NAMESPACE(antlr)RefAST(tmp101_AST));

                      }

                      match(RPAREN);

                 }

                 else {

                      goto _loop129;

                 }

           }

           _loop129:;

           } // ( ... )*

           attribute_AST = RefTNode(currentAST.root);

      }

      catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {

           if( inputState->guessing == 0 ) {

                 reportError(ex);

                 recover(ex,_tokenSet_5);

           } else {

                 throw;

           }

      }

      returnAST = attribute_AST;

}

The words in yellow are proposed to be "RefToken" but "RefAST". This is the
only mistake. I am confused totally! 

I sincerely hope you can help me!

When we solve this problem, I will share it in the Internet!

I am looking forwards to hearing from you!

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060924/37d64b7e/attachment-0001.html 


More information about the antlr-interest mailing list