2 #include "VhdlParserTokenManager.h"
3 #include "VhdlParserErrorHandler.hpp"
4 #include "VhdlParser.h"
5 #include "VhdlParserIF.h"
6 #include "CharStream.h"
8 using namespace vhdl::parser;
10 static VhdlParser * myParser=0;
12 void VhdlParserIF::parseVhdlfile(const char* inputBuffer,bool inLine)
14 JAVACC_STRING_TYPE s =inputBuffer;
15 CharStream *stream = new CharStream(s.c_str(), (int)s.size(), 1, 1);
16 VhdlParserTokenManager *tokenManager = new VhdlParserTokenManager(stream);
17 VhdlTokenManagerErrorHandler *myTokErr=new VhdlTokenManagerErrorHandler();
18 tokenManager->setErrorHandler(myTokErr);
19 myParser=new VhdlParser(tokenManager);
20 VhdlErrorHandler *myErr=new VhdlErrorHandler();
21 myParser->setErrorHandler(myErr);
26 myParser->parseInline();
30 myParser->design_file();
33 catch( std::exception &){ /* fprintf(stderr,"\n[%s]",e.what()); */ }
34 // fprintf(stderr,"\n\nparsed lines: %d\n",yyLineNr);
35 // fprintf(stderr,"\n\nerrors : %d\n\n",myErr->getErrorCount());
41 void VhdlParser::error_skipto(int kind)
46 Token *t = myParser->getNextToken();// step to next token
47 op=myParser->getToken(1); // get first token
49 //fprintf(stderr,"\n %s",t->image.data());
50 } while (op->kind != kind);
51 myParser->hasError=false;
52 // The above loop consumes tokens all the way up to a token of
53 // "kind". We use a do-while loop rather than a while because the
54 // current token is the one immediately before the erroneous token
55 // (in our case the token immediately before what should have been