Imported Upstream version 1.8.8
[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   myParser=new VhdlParser(tokenManager);
18   VhdlErrorHandler *myErr=new VhdlErrorHandler();
19   myParser->setErrorHandler(myErr);
20   try
21   {
22     if(inLine)
23     {
24       myParser->parseInline();
25     }
26     else
27     {
28       myParser->design_file();
29     }
30   }
31   catch( std::exception &){ /* fprintf(stderr,"\n[%s]",e.what()); */ }
32   //  fprintf(stderr,"\n\nparsed lines: %d\n",yyLineNr);
33   //  fprintf(stderr,"\n\nerrors : %d\n\n",myErr->getErrorCount());
34   delete myParser;
35  
36 }
37
38 void VhdlParser::error_skipto(int kind)
39 {
40   Token *op;
41   do
42   {
43      Token *t = myParser->getNextToken();// step to next token
44          op=myParser->getToken(1);           // get first token
45      if (op==0) break;
46     //fprintf(stderr,"\n %s",t->image.data());
47   } while (op->kind != kind);
48   myParser->hasError=false;
49   // The above loop consumes tokens all the way up to a token of
50   // "kind".  We use a do-while loop rather than a while because the
51   // current token is the one immediately before the erroneous token
52   // (in our case the token immediately before what should have been
53   // "if"/"while".
54
55 }