Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / vhdlparser / VhdlParserIF.cpp
1
2 #include "VhdlParserTokenManager.h"
3 #include "VhdlParserErrorHandler.hpp"
4 #include "VhdlParser.h"
5 #include "VhdlParserIF.h"
6 #include "CharStream.h"
7
8 using namespace vhdl::parser;
9
10 static VhdlParser * myParser=0;
11
12 void  VhdlParserIF::parseVhdlfile(const char* inputBuffer,bool inLine) 
13 {
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);
22   try
23   {
24     if(inLine)
25     {
26       myParser->parseInline();
27     }
28     else
29     {
30       myParser->design_file();
31     }
32   }
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());
36   delete myParser;
37   delete myErr;
38  
39 }
40
41 void VhdlParser::error_skipto(int kind)
42 {
43   Token *op;
44   do
45   {
46      Token *t = myParser->getNextToken();// step to next token
47          op=myParser->getToken(1);           // get first token
48      if (op==0) break;
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
56   // "if"/"while".
57
58 }