summaryrefslogtreecommitdiffstats
path: root/vhdlparser/VhdlParserIF.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2014-07-27 14:31:34 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2014-08-02 10:05:26 (GMT)
commit36122e49ed1d9e640b1ceca52536ec7c55e10474 (patch)
treec61b21164b0445eb23631aa812810f4712cd8f61 /vhdlparser/VhdlParserIF.cpp
parent6a60477b418e21dbadd3e62dc557a038e319581b (diff)
downloadDoxygen-36122e49ed1d9e640b1ceca52536ec7c55e10474.zip
Doxygen-36122e49ed1d9e640b1ceca52536ec7c55e10474.tar.gz
Doxygen-36122e49ed1d9e640b1ceca52536ec7c55e10474.tar.bz2
New VHDL parser implementation
Diffstat (limited to 'vhdlparser/VhdlParserIF.cpp')
-rw-r--r--vhdlparser/VhdlParserIF.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/vhdlparser/VhdlParserIF.cpp b/vhdlparser/VhdlParserIF.cpp
new file mode 100644
index 0000000..1369b73
--- /dev/null
+++ b/vhdlparser/VhdlParserIF.cpp
@@ -0,0 +1,56 @@
+
+#include "VhdlParserTokenManager.h"
+#include "VhdlParserErrorHandler.hpp"
+#include "VhdlParser.h"
+#include "VhdlParserIF.h"
+#include "CharStream.h"
+
+using namespace vhdl::parser;
+
+static VhdlParser * myParser;
+
+void VhdlParserIF::parseVhdlfile(const char* inputBuffer,bool inLine)
+{
+ JAVACC_STRING_TYPE s =inputBuffer;
+ CharStream *stream = new CharStream(s.c_str(), (int)s.size(), 1, 1);
+ VhdlParserTokenManager *tokenManager = new VhdlParserTokenManager(stream);
+ myParser=new VhdlParser(tokenManager);
+ VhdlErrorHandler *myErr=new VhdlErrorHandler();
+ myParser->setErrorHandler(myErr);
+ try
+ {
+ if(inLine)
+ {
+ myParser->parseInline();
+ }
+ else
+ {
+ myParser->design_file();
+ }
+ }
+ catch( std::exception &)
+ {
+ /* fprintf(stderr,"\n[%s]",e.what()); */
+ }
+ // fprintf(stderr,"\n\nparsed lines: %d\n",yyLineNr);
+ // fprintf(stderr,"\n\nerrors : %d\n\n",myErr->getErrorCount());
+ delete myParser;
+}
+
+void VhdlParser::error_skipto(int kind)
+{
+ Token *op;
+ do
+ {
+ op=myParser->getToken(1);
+ if (op==0) break;
+ //fprintf(stderr,"\n %s",t->image.data());
+ } while (op->kind != kind);
+ myParser->hasError=false;
+ // The above loop consumes tokens all the way up to a token of
+ // "kind". We use a do-while loop rather than a while because the
+ // current token is the one immediately before the erroneous token
+ // (in our case the token immediately before what should have been
+ // "if"/"while".
+
+}