VhdlParserIF.cpp
Go to the documentation of this file.
1 
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);
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  delete myErr;
36 
37 }
38 
40 {
41  Token *op;
42  do
43  {
44  Token *t = myParser->getNextToken();// step to next token
45  op=myParser->getToken(1); // get first token
46  if (op==0) break;
47  //fprintf(stderr,"\n %s",t->image.data());
48  } while (op->kind != kind);
49  myParser->hasError=false;
50  // The above loop consumes tokens all the way up to a token of
51  // "kind". We use a do-while loop rather than a while because the
52  // current token is the one immediately before the erroneous token
53  // (in our case the token immediately before what should have been
54  // "if"/"while".
55 
56 }
static VhdlParser * myParser
void setErrorHandler(ErrorHandler *eh)
Definition: VhdlParser.h:8895
#define JAVACC_STRING_TYPE
Definition: JavaCC.h:16
static void error_skipto(int kind)
Token * getToken(int index)
static void parseVhdlfile(const char *inputBuffer, bool inLine)
static QCString * s
Definition: config.cpp:1042
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33