diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2015-01-03 13:11:32 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2015-01-03 13:49:24 (GMT) |
commit | 088896f27f460b6ac03c2d64df148e3617c1e519 (patch) | |
tree | 5b0c250c54a6ede082f765d507d749fad52b0756 | |
parent | d75455eef7c91f11c2b9061d9a086ce93c4231b2 (diff) | |
download | Doxygen-088896f27f460b6ac03c2d64df148e3617c1e519.zip Doxygen-088896f27f460b6ac03c2d64df148e3617c1e519.tar.gz Doxygen-088896f27f460b6ac03c2d64df148e3617c1e519.tar.bz2 |
Switched back to version 6.2 of JavaCC for VHDL parser generation.
-rw-r--r-- | vhdlparser/CharStream.cc | 4 | ||||
-rw-r--r-- | vhdlparser/CharStream.h | 190 | ||||
-rw-r--r-- | vhdlparser/ErrorHandler.h | 44 | ||||
-rw-r--r-- | vhdlparser/ParseException.cc | 6 | ||||
-rw-r--r-- | vhdlparser/ParseException.h | 4 | ||||
-rw-r--r-- | vhdlparser/Token.cc | 4 | ||||
-rw-r--r-- | vhdlparser/Token.h | 7 | ||||
-rw-r--r-- | vhdlparser/TokenManager.h | 13 | ||||
-rw-r--r-- | vhdlparser/TokenMgrError.cc | 15 | ||||
-rw-r--r-- | vhdlparser/TokenMgrError.h | 23 | ||||
-rw-r--r-- | vhdlparser/VhdlParser.cc | 52 | ||||
-rw-r--r-- | vhdlparser/VhdlParser.h | 316 | ||||
-rw-r--r-- | vhdlparser/VhdlParserConstants.h | 1 | ||||
-rw-r--r-- | vhdlparser/VhdlParserTokenManager.cc | 142 | ||||
-rw-r--r-- | vhdlparser/VhdlParserTokenManager.h | 29 | ||||
-rw-r--r-- | vhdlparser/vhdlstring.h | 4 |
16 files changed, 481 insertions, 373 deletions
diff --git a/vhdlparser/CharStream.cc b/vhdlparser/CharStream.cc index 8cc17c3..65179f5 100644 --- a/vhdlparser/CharStream.cc +++ b/vhdlparser/CharStream.cc @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. CharStream.cc Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. CharStream.cc Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #include "CharStream.h" @@ -209,4 +209,4 @@ void CharStream::UpdateLineColumn(JAVACC_CHAR_TYPE c) { } } -/* JavaCC - OriginalChecksum=e709b9ee1adf0fcb6b1c5e1641f10348 (do not edit this line) */ +/* JavaCC - OriginalChecksum=ade3c1b57a731a003629de593814ffa6 (do not edit this line) */ diff --git a/vhdlparser/CharStream.h b/vhdlparser/CharStream.h index b0e74b6..409439f 100644 --- a/vhdlparser/CharStream.h +++ b/vhdlparser/CharStream.h @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. CharStream.h Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. CharStream.h Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #ifndef CHARSTREAM_H #define CHARSTREAM_H @@ -28,17 +28,17 @@ namespace parser { class CharStream { - public: - void setTabSize(int i) { tabSize = i; } - int getTabSize(int) { return tabSize; } - virtual int getColumn() { return trackLineColumn ? bufcolumn[bufpos] : -1; } - virtual int getLine() { return trackLineColumn ? bufline[bufpos] : -1; } - virtual int getEndColumn() { return trackLineColumn ? bufcolumn[bufpos] : -1; } - virtual int getEndLine() { return trackLineColumn ? bufline[bufpos] : -1; } - virtual int getBeginColumn() { return trackLineColumn ? bufcolumn[tokenBegin] : -1; } - virtual int getBeginLine() { return trackLineColumn ? bufline[tokenBegin] : -1; } - - virtual bool getTrackLineColumn() { return trackLineColumn; } +public: + void setTabSize(int i) { tabSize = i; } + int getTabSize(int) { return tabSize; } + virtual int getColumn() { return trackLineColumn ? bufcolumn[bufpos] : -1; } + virtual int getLine() { return trackLineColumn ? bufline[bufpos] : -1; } + virtual int getEndColumn() { return trackLineColumn ? bufcolumn[bufpos] : -1; } + virtual int getEndLine() { return trackLineColumn ? bufline[bufpos] : -1; } + virtual int getBeginColumn() { return trackLineColumn ? bufcolumn[tokenBegin] : -1; } + virtual int getBeginLine() { return trackLineColumn ? bufline[tokenBegin] : -1; } + + virtual bool getTrackLineColumn() { return trackLineColumn; } virtual void setTrackLineColumn(bool val) { trackLineColumn = val; } /** @@ -47,25 +47,25 @@ class CharStream { * (longer) token. So, they will be used again as the prefix of the next * token and it is the implemetation's responsibility to do this right. */ -virtual inline void backup(int amount) { - inBuf += amount; - bufpos -= amount; - if (bufpos < 0) { - bufpos += bufsize; + virtual inline void backup(int amount) { + inBuf += amount; + bufpos -= amount; + if (bufpos < 0) { + bufpos += bufsize; + } } -} /** * Returns the next character that marks the beginning of the next token. * All characters must remain in the buffer between two successive calls * to this method to implement backup correctly. */ -virtual inline JAVACC_CHAR_TYPE BeginToken() { - tokenBegin = -1; - JAVACC_CHAR_TYPE c = readChar(); - tokenBegin = bufpos; - return c; -} + virtual inline JAVACC_CHAR_TYPE BeginToken() { + tokenBegin = -1; + JAVACC_CHAR_TYPE c = readChar(); + tokenBegin = bufpos; + return c; + } /** @@ -73,31 +73,30 @@ virtual inline JAVACC_CHAR_TYPE BeginToken() { * of selecting the input is the responsibility of the class * implementing this class. */ -virtual inline JAVACC_CHAR_TYPE readChar() { - if (inBuf > 0) { - --inBuf; - ++bufpos; - if (bufpos == bufsize) { - bufpos = 0; + virtual inline JAVACC_CHAR_TYPE readChar() { + if (inBuf > 0) { + --inBuf; + ++bufpos; + if (bufpos == bufsize) { + bufpos = 0; + } + return buffer[bufpos]; } - return buffer[bufpos]; - } + ++bufpos; + if (bufpos >= maxNextCharInd) { + FillBuff(); + } - ++bufpos; - if (bufpos >= maxNextCharInd) { - FillBuff(); - } + JAVACC_CHAR_TYPE c = buffer[bufpos]; - JAVACC_CHAR_TYPE c = buffer[bufpos]; + if (trackLineColumn) { + UpdateLineColumn(c); + } - if (trackLineColumn) { - UpdateLineColumn(c); + return c; } - return c; -} - virtual void ExpandBuff(bool wrapAround); virtual void FillBuff(); @@ -112,8 +111,7 @@ virtual inline JAVACC_CHAR_TYPE readChar() { if (bufpos >= tokenBegin) return JAVACC_STRING_TYPE(buffer + tokenBegin, bufpos - tokenBegin + 1); else - return JAVACC_STRING_TYPE(buffer + tokenBegin, bufsize - tokenBegin) - .append(buffer, bufpos + 1); + return JAVACC_STRING_TYPE(buffer + tokenBegin, bufsize - tokenBegin).append(buffer, bufpos + 1); } /** @@ -126,8 +124,7 @@ virtual inline JAVACC_CHAR_TYPE readChar() { if ((bufpos + 1) >= len) { return JAVACC_STRING_TYPE(buffer + bufpos - len + 1, len); } - return JAVACC_STRING_TYPE(buffer + bufsize - (len - bufpos - 1), len - bufpos - 1) - .append(buffer, bufpos + 1); + return JAVACC_STRING_TYPE(buffer + bufsize - (len - bufpos - 1), len - bufpos - 1).append(buffer, bufpos + 1); } /** @@ -144,74 +141,71 @@ virtual inline JAVACC_CHAR_TYPE readChar() { } bool endOfInput() { - return inBuf == 0 && bufpos + 1 >= maxNextCharInd && - inputStream->endOfInput(); + return inBuf == 0 && bufpos + 1 >= maxNextCharInd && inputStream->endOfInput(); } CharStream(const JAVACC_CHAR_TYPE *buf, int sz, int startline, int startcolumn, int buffersize) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(JAVACC_STRING_TYPE(buf, sz), startline, startcolumn, buffersize); } CharStream(const JAVACC_CHAR_TYPE *buf, int sz, int startline, int startcolumn) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(JAVACC_STRING_TYPE(buf, sz), startline, startcolumn, INITIAL_BUFFER_SIZE); } CharStream(const JAVACC_STRING_TYPE& str, int startline, int startcolumn, int buffersize) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(str, startline, startcolumn, buffersize); } CharStream(const JAVACC_STRING_TYPE& str, int startline, int startcolumn) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0) ,tabSize(8), trackLineColumn(true){ + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(str, startline, startcolumn, INITIAL_BUFFER_SIZE); } CharStream(ReaderStream *input_stream, int startline, int startcolumn, int) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(input_stream, startline, startcolumn, INITIAL_BUFFER_SIZE); } CharStream(ReaderStream *input_stream, int startline, int startcolumn) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(input_stream, startline, startcolumn, INITIAL_BUFFER_SIZE); } CharStream(ReaderStream *input_stream) : - bufline(NULL), bufcolumn(NULL), inputStream(NULL), deleteStream(false), - buffer(NULL), bufpos(0), bufsize(0), tokenBegin(0), column(0), line(0), - prevCharIsCR (false), prevCharIsLF (false), available(0), maxNextCharInd(0), - inBuf(0),tabSize(8), trackLineColumn(true) { + bufline(NULL), bufcolumn(NULL), buffer(NULL), bufpos(0), bufsize(0), + tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false), + available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true), + inputStream(NULL), deleteStream(false) { ReInit(input_stream, 1, 1, INITIAL_BUFFER_SIZE); } - virtual void ReInit(ReaderStream *input_stream, int startline, int startcolumn, - int buffersize); + virtual void ReInit(ReaderStream *input_stream, int startline, int startcolumn, int buffersize); - virtual void ReInit(ReaderStream *input_stream, int startline, - int startcolumn) { + virtual void ReInit(ReaderStream *input_stream, int startline, int startcolumn) { ReInit(input_stream, startline, startcolumn, INITIAL_BUFFER_SIZE); } @@ -232,26 +226,26 @@ virtual inline JAVACC_CHAR_TYPE readChar() { protected: virtual void UpdateLineColumn(JAVACC_CHAR_TYPE c); - int *bufline; - int *bufcolumn; - ReaderStream *inputStream; - bool deleteStream; - JAVACC_CHAR_TYPE * buffer; - int bufpos; - int bufsize; - int tokenBegin; - int column; - int line; - bool prevCharIsCR ; - bool prevCharIsLF ; - int available; - int maxNextCharInd; - int inBuf ; - int tabSize ; - bool trackLineColumn; + int* bufline; + int* bufcolumn; + JAVACC_CHAR_TYPE* buffer; + int bufpos; + int bufsize; + int tokenBegin; + int column; + int line; + bool prevCharIsCR; + bool prevCharIsLF; + int available; + int maxNextCharInd; + int inBuf; + int tabSize; + bool trackLineColumn; + ReaderStream* inputStream; + bool deleteStream; }; } } #endif -/* JavaCC - OriginalChecksum=5eaf75ef6a2c7859369c80cf6fd037e0 (do not edit this line) */ +/* JavaCC - OriginalChecksum=89f4cb30f0d3487ee809cca18a2924f2 (do not edit this line) */ diff --git a/vhdlparser/ErrorHandler.h b/vhdlparser/ErrorHandler.h index 9f0d38c..2170489 100644 --- a/vhdlparser/ErrorHandler.h +++ b/vhdlparser/ErrorHandler.h @@ -1,15 +1,21 @@ -/* Generated By:JavaCC: Do not edit this line. ErrorHandler.h Version 6.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* Generated By:JavaCC: Do not edit this line. ErrorHandler.h Version 6.2 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,BUILD_PARSER=true,BUILD_TOKEN_MANAGER=true */ #ifndef ERRORHANDLER_H #define ERRORHANDLER_H +#include <stdio.h> #include <string> #include "JavaCC.h" #include "Token.h" namespace vhdl { namespace parser { -class VhdlParser; + +JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str); + + class VhdlParser; class ErrorHandler { + friend class VhdlParserTokenManager; + friend class VhdlParser; protected: int error_count; public: @@ -33,11 +39,41 @@ class VhdlParser; virtual int getErrorCount() { return error_count; } + virtual void handleOtherError(JAVACC_STRING_TYPE message, VhdlParser *) { + fprintf(stderr, "Error: %s\n", (char*)message.c_str()); + } virtual ~ErrorHandler() {} ErrorHandler() { error_count = 0; } }; + + class VhdlParserTokenManager; + class TokenManagerErrorHandler { + friend class VhdlParserTokenManager; + protected: + int error_count; + public: + // Returns a detailed message for the Error when it is thrown by the + // token manager to indicate a lexical error. + // Parameters : + // EOFSeen : indicates if EOF caused the lexical error + // curLexState : lexical state in which this error occurred + // errorLine : line number when the error occurred + // errorColumn : column number when the error occurred + // errorAfter : prefix that was seen before this error occurred + // curchar : the offending character + // + virtual void lexicalError(bool EOFSeen, int, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, VhdlParserTokenManager*) { + // by default, we just print an error message and return. + fprintf(stderr, "Lexical error at: %d:%d. Encountered: %c after: %s.\n", errorLine, errorColumn, curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str())); + } + virtual void lexicalError(JAVACC_STRING_TYPE errorMessage, VhdlParserTokenManager*) { + fprintf(stderr, "%s\n", (char*)errorMessage.c_str()); + } + virtual ~TokenManagerErrorHandler() {} + }; + } } #endif -/* JavaCC - OriginalChecksum=282223c3bcb53b7ff385aed35944d185 (do not edit this line) */ +/* JavaCC - OriginalChecksum=c18f1105ba178be8e21cc9f279f94496 (do not edit this line) */ diff --git a/vhdlparser/ParseException.cc b/vhdlparser/ParseException.cc index 31ee7a3..6ef9738 100644 --- a/vhdlparser/ParseException.cc +++ b/vhdlparser/ParseException.cc @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.cc Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. ParseException.cc Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #include "ParseException.h" @@ -141,8 +141,6 @@ namespace parser { for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { - case 0 : - continue; case '\b': retval.append("\\b"); continue; @@ -183,4 +181,4 @@ namespace parser { } } -/* JavaCC - OriginalChecksum=99d488e13335cf377284c90700f070ed (do not edit this line) */ +/* JavaCC - OriginalChecksum=9f6af8fd72f5fe3e4210cf02acbd8387 (do not edit this line) */ diff --git a/vhdlparser/ParseException.h b/vhdlparser/ParseException.h index 1f3a3dc..c36613f 100644 --- a/vhdlparser/ParseException.h +++ b/vhdlparser/ParseException.h @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.h Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. ParseException.h Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #ifndef _PARSE_EXCEPTION_H #define _PARSE_EXCEPTION_H @@ -96,4 +96,4 @@ class ParseException { } } #endif -/* JavaCC - OriginalChecksum=8c47c56fc2030f05b43e20cae6ca5d66 (do not edit this line) */ +/* JavaCC - OriginalChecksum=bd87c2fc11a4306bd2c2482fd1025b7c (do not edit this line) */ diff --git a/vhdlparser/Token.cc b/vhdlparser/Token.cc index 62a8169..735091d 100644 --- a/vhdlparser/Token.cc +++ b/vhdlparser/Token.cc @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. Token.cc Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. Token.cc Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,TOKEN_INCLUDES=,TOKEN_EXTENDS= */ #include "Token.h" @@ -89,4 +89,4 @@ namespace parser { } } -/* JavaCC - OriginalChecksum=9db9ca693072c4c37bb7cc933c0c5e35 (do not edit this line) */ +/* JavaCC - OriginalChecksum=dcb0f64486aa6455ae5af05d6bb539ec (do not edit this line) */ diff --git a/vhdlparser/Token.h b/vhdlparser/Token.h index 5fce69f..040899e 100644 --- a/vhdlparser/Token.h +++ b/vhdlparser/Token.h @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. Token.h Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. Token.h Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,TOKEN_INCLUDES=,TOKEN_EXTENDS= */ #ifndef TOKEN_H #define TOKEN_H @@ -86,12 +86,13 @@ class Token */ Token(int kind, JAVACC_STRING_TYPE image); + virtual ~Token(); + /** * Returns the image. */ JAVACC_STRING_TYPE toString(); - public: virtual ~Token(); /** * Returns a new Token void *, by default. However, if you want, you @@ -113,4 +114,4 @@ class Token } } #endif -/* JavaCC - OriginalChecksum=2f5eb1c937adc983dfa2008c4fe383a7 (do not edit this line) */ +/* JavaCC - OriginalChecksum=4748c3d6443aa3445d3c95ab54f14c2a (do not edit this line) */ diff --git a/vhdlparser/TokenManager.h b/vhdlparser/TokenManager.h index b0b8b98..775e43d 100644 --- a/vhdlparser/TokenManager.h +++ b/vhdlparser/TokenManager.h @@ -1,11 +1,10 @@ -/* Generated By:JavaCC: Do not edit this line. TokenManager.h Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. TokenManager.h Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #ifndef TOKENMANAGER_H #define TOKENMANAGER_H #include "JavaCC.h" #include "Token.h" - namespace vhdl { namespace parser { /** @@ -19,10 +18,10 @@ public: /** This gets the next token from the input stream. * A token of kind 0 (<EOF>) should be returned on EOF. */ - public: virtual Token *getNextToken() = 0; - public: virtual ~TokenManager() { } - public: virtual void lexicalError() { - fprintf(stderr, "Lexical error encountered"); + virtual ~TokenManager() { } + virtual Token *getNextToken() = 0; + virtual void lexicalError() { + fprintf(stderr,"Lexical error encountered."); } }; @@ -30,4 +29,4 @@ public: } } #endif -/* JavaCC - OriginalChecksum=d4725ee75465725057819b3b07fadaa7 (do not edit this line) */ +/* JavaCC - OriginalChecksum=918e2eba53e028d6c4142283ce3f498f (do not edit this line) */ diff --git a/vhdlparser/TokenMgrError.cc b/vhdlparser/TokenMgrError.cc index 0be1213..6231196 100644 --- a/vhdlparser/TokenMgrError.cc +++ b/vhdlparser/TokenMgrError.cc @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.cc Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.cc Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #include "TokenMgrError.h" @@ -61,11 +61,8 @@ namespace parser { errorCode = reason; } -} -} - // i < 16 - guaranteed -static char hexChar(int i) { +char hexChar(int i) { if (i < 10) { return i - '0'; } @@ -82,9 +79,6 @@ JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str) { JAVACC_CHAR_TYPE ch = str[i]; switch (ch) { - case 0 : - retval += EMPTY[0]; - continue; case '\b': retval.append("\\b"); continue; @@ -118,4 +112,7 @@ JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str) { } return retval; } -/* JavaCC - OriginalChecksum=7f80e3c4eac120168f5e81d4ddb72e4b (do not edit this line) */ + +} +} +/* JavaCC - OriginalChecksum=2fe11435e6701b2fca885354b08bfdf6 (do not edit this line) */ diff --git a/vhdlparser/TokenMgrError.h b/vhdlparser/TokenMgrError.h index 2702b29..abb305d 100644 --- a/vhdlparser/TokenMgrError.h +++ b/vhdlparser/TokenMgrError.h @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.h Version 6.0 */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.h Version 6.2 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ #ifndef _TOKENMGRERROR_H #define _TOKENMGRERROR_H @@ -8,7 +8,7 @@ namespace vhdl { namespace parser { - enum LexerErrors { +enum LexerErrors { /** * Lexical error occurred. */ @@ -28,11 +28,10 @@ namespace parser { * Detected (and bailed out of) an infinite loop in the token manager. */ LOOP_DETECTED = 3, - }; +}; -class TokenMgrError -{ - public: +class TokenMgrError { +public: /* * Ordinals for various reasons why an Error of this type can be thrown. */ @@ -57,7 +56,8 @@ class TokenMgrError */ JAVACC_STRING_TYPE LexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar); - private: JAVACC_STRING_TYPE message; +private: + JAVACC_STRING_TYPE message; /** * You can also modify the body of this method to customize your error messages. @@ -68,6 +68,7 @@ class TokenMgrError * * from this method for such cases in the release version of your parser. */ +public: JAVACC_STRING_TYPE getMessage() ; /* @@ -75,16 +76,16 @@ class TokenMgrError */ /** No arg constructor. */ - public: TokenMgrError() ; + TokenMgrError() ; /** Constructor with message and reason. */ - public: TokenMgrError(JAVACC_STRING_TYPE message, int reason) ; + TokenMgrError(JAVACC_STRING_TYPE message, int reason) ; /** Full Constructor. */ - public: TokenMgrError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, int reason) ; + TokenMgrError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, int reason) ; }; } } #endif -/* JavaCC - OriginalChecksum=c7d825cb4d037b031ae43569d383f738 (do not edit this line) */ +/* JavaCC - OriginalChecksum=c22a1b25630ec91deb47dcba22b6b39d (do not edit this line) */ diff --git a/vhdlparser/VhdlParser.cc b/vhdlparser/VhdlParser.cc index 39a1308..c695c93 100644 --- a/vhdlparser/VhdlParser.cc +++ b/vhdlparser/VhdlParser.cc @@ -1,5 +1,6 @@ /* VhdlParser.cc */ -#include "./VhdlParser.h" +#include "VhdlParser.h" +#include "TokenMgrError.h" namespace vhdl { namespace parser { unsigned int jj_la1_0[] = { @@ -12753,26 +12754,16 @@ void VhdlParser::parseInline() { VhdlParser::VhdlParser(TokenManager *tm){ head = NULL; + errorHandlerCreated = false; ReInit(tm); } - VhdlParser::~VhdlParser() +VhdlParser::~VhdlParser() { - if (token_source) delete token_source; - if (head) { - Token *next, *t = head; - while (t) { - next = t->next; - delete t; - t = next; - } - } - if (errorHandlerCreated) { - delete errorHandler; - } + clear(); } void VhdlParser::ReInit(TokenManager *tm){ - if (head) delete head; + clear(); errorHandler = new ErrorHandler(); errorHandlerCreated = true; hasError = false; @@ -12794,6 +12785,24 @@ void VhdlParser::ReInit(TokenManager *tm){ } +void VhdlParser::clear(){ + //Since token manager was generate from outside, + //parser should not take care of deleting + //if (token_source) delete token_source; + if (head) { + Token *next, *t = head; + while (t) { + next = t->next; + delete t; + t = next; + } + } + if (errorHandlerCreated) { + delete errorHandler; + } +} + + Token * VhdlParser::jj_consume_token(int kind) { Token *oldToken; if ((oldToken = token)->next != NULL) token = token->next; @@ -12873,26 +12882,23 @@ int VhdlParser::jj_ntk_f(){ } -void VhdlParser::jj_add_error_token(int kind, int pos) { + void VhdlParser::jj_add_error_token(int kind, int pos) { } - /** Generate ParseException. */ void VhdlParser::parseError() { fprintf(stderr, "Parse error at: %d:%d, after token: %s encountered: %s\n", token->beginLine, token->beginColumn, addUnicodeEscapes(token->image).c_str(), addUnicodeEscapes(getToken(1)->image).c_str()); } - void VhdlParser::enable_tracing() { + void VhdlParser::enable_tracing() { } - /** Disable tracing. */ - - void VhdlParser::disable_tracing() { + void VhdlParser::disable_tracing() { } -void VhdlParser::jj_rescan_token(){ + void VhdlParser::jj_rescan_token(){ jj_rescan = true; for (int i = 0; i < 114; i++) { JJCalls *p = &jj_2_rtns[i]; @@ -13023,7 +13029,7 @@ void VhdlParser::jj_rescan_token(){ } -void VhdlParser::jj_save(int index, int xla){ + void VhdlParser::jj_save(int index, int xla){ JJCalls *p = &jj_2_rtns[index]; while (p->gen > jj_gen) { if (p->next == NULL) { p = p->next = new JJCalls(); break; } diff --git a/vhdlparser/VhdlParser.h b/vhdlparser/VhdlParser.h index 4d41c74..91bf32d 100644 --- a/vhdlparser/VhdlParser.h +++ b/vhdlparser/VhdlParser.h @@ -12,12 +12,12 @@ namespace vhdl { namespace parser { struct JJCalls { - int gen; - Token *first; - int arg; - JJCalls *next; + int gen; + int arg; + JJCalls* next; + Token* first; ~JJCalls() { if (next) delete next; } - JJCalls() { next = NULL; arg = 0; gen = -1; first = NULL; } + JJCalls() { next = NULL; arg = 0; gen = -1; first = NULL; } }; class VhdlParser { @@ -583,7 +583,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_1() || jj_done; - finally { jj_save(0, xla); } + { jj_save(0, xla); } } inline bool jj_2_2(int xla) @@ -591,7 +591,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_2() || jj_done; - finally { jj_save(1, xla); } + { jj_save(1, xla); } } inline bool jj_2_3(int xla) @@ -599,7 +599,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_3() || jj_done; - finally { jj_save(2, xla); } + { jj_save(2, xla); } } inline bool jj_2_4(int xla) @@ -607,7 +607,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_4() || jj_done; - finally { jj_save(3, xla); } + { jj_save(3, xla); } } inline bool jj_2_5(int xla) @@ -615,7 +615,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_5() || jj_done; - finally { jj_save(4, xla); } + { jj_save(4, xla); } } inline bool jj_2_6(int xla) @@ -623,7 +623,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_6() || jj_done; - finally { jj_save(5, xla); } + { jj_save(5, xla); } } inline bool jj_2_7(int xla) @@ -631,7 +631,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_7() || jj_done; - finally { jj_save(6, xla); } + { jj_save(6, xla); } } inline bool jj_2_8(int xla) @@ -639,7 +639,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_8() || jj_done; - finally { jj_save(7, xla); } + { jj_save(7, xla); } } inline bool jj_2_9(int xla) @@ -647,7 +647,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_9() || jj_done; - finally { jj_save(8, xla); } + { jj_save(8, xla); } } inline bool jj_2_10(int xla) @@ -655,7 +655,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_10() || jj_done; - finally { jj_save(9, xla); } + { jj_save(9, xla); } } inline bool jj_2_11(int xla) @@ -663,7 +663,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_11() || jj_done; - finally { jj_save(10, xla); } + { jj_save(10, xla); } } inline bool jj_2_12(int xla) @@ -671,7 +671,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_12() || jj_done; - finally { jj_save(11, xla); } + { jj_save(11, xla); } } inline bool jj_2_13(int xla) @@ -679,7 +679,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_13() || jj_done; - finally { jj_save(12, xla); } + { jj_save(12, xla); } } inline bool jj_2_14(int xla) @@ -687,7 +687,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_14() || jj_done; - finally { jj_save(13, xla); } + { jj_save(13, xla); } } inline bool jj_2_15(int xla) @@ -695,7 +695,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_15() || jj_done; - finally { jj_save(14, xla); } + { jj_save(14, xla); } } inline bool jj_2_16(int xla) @@ -703,7 +703,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_16() || jj_done; - finally { jj_save(15, xla); } + { jj_save(15, xla); } } inline bool jj_2_17(int xla) @@ -711,7 +711,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_17() || jj_done; - finally { jj_save(16, xla); } + { jj_save(16, xla); } } inline bool jj_2_18(int xla) @@ -719,7 +719,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_18() || jj_done; - finally { jj_save(17, xla); } + { jj_save(17, xla); } } inline bool jj_2_19(int xla) @@ -727,7 +727,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_19() || jj_done; - finally { jj_save(18, xla); } + { jj_save(18, xla); } } inline bool jj_2_20(int xla) @@ -735,7 +735,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_20() || jj_done; - finally { jj_save(19, xla); } + { jj_save(19, xla); } } inline bool jj_2_21(int xla) @@ -743,7 +743,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_21() || jj_done; - finally { jj_save(20, xla); } + { jj_save(20, xla); } } inline bool jj_2_22(int xla) @@ -751,7 +751,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_22() || jj_done; - finally { jj_save(21, xla); } + { jj_save(21, xla); } } inline bool jj_2_23(int xla) @@ -759,7 +759,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_23() || jj_done; - finally { jj_save(22, xla); } + { jj_save(22, xla); } } inline bool jj_2_24(int xla) @@ -767,7 +767,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_24() || jj_done; - finally { jj_save(23, xla); } + { jj_save(23, xla); } } inline bool jj_2_25(int xla) @@ -775,7 +775,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_25() || jj_done; - finally { jj_save(24, xla); } + { jj_save(24, xla); } } inline bool jj_2_26(int xla) @@ -783,7 +783,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_26() || jj_done; - finally { jj_save(25, xla); } + { jj_save(25, xla); } } inline bool jj_2_27(int xla) @@ -791,7 +791,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_27() || jj_done; - finally { jj_save(26, xla); } + { jj_save(26, xla); } } inline bool jj_2_28(int xla) @@ -799,7 +799,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_28() || jj_done; - finally { jj_save(27, xla); } + { jj_save(27, xla); } } inline bool jj_2_29(int xla) @@ -807,7 +807,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_29() || jj_done; - finally { jj_save(28, xla); } + { jj_save(28, xla); } } inline bool jj_2_30(int xla) @@ -815,7 +815,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_30() || jj_done; - finally { jj_save(29, xla); } + { jj_save(29, xla); } } inline bool jj_2_31(int xla) @@ -823,7 +823,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_31() || jj_done; - finally { jj_save(30, xla); } + { jj_save(30, xla); } } inline bool jj_2_32(int xla) @@ -831,7 +831,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_32() || jj_done; - finally { jj_save(31, xla); } + { jj_save(31, xla); } } inline bool jj_2_33(int xla) @@ -839,7 +839,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_33() || jj_done; - finally { jj_save(32, xla); } + { jj_save(32, xla); } } inline bool jj_2_34(int xla) @@ -847,7 +847,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_34() || jj_done; - finally { jj_save(33, xla); } + { jj_save(33, xla); } } inline bool jj_2_35(int xla) @@ -855,7 +855,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_35() || jj_done; - finally { jj_save(34, xla); } + { jj_save(34, xla); } } inline bool jj_2_36(int xla) @@ -863,7 +863,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_36() || jj_done; - finally { jj_save(35, xla); } + { jj_save(35, xla); } } inline bool jj_2_37(int xla) @@ -871,7 +871,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_37() || jj_done; - finally { jj_save(36, xla); } + { jj_save(36, xla); } } inline bool jj_2_38(int xla) @@ -879,7 +879,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_38() || jj_done; - finally { jj_save(37, xla); } + { jj_save(37, xla); } } inline bool jj_2_39(int xla) @@ -887,7 +887,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_39() || jj_done; - finally { jj_save(38, xla); } + { jj_save(38, xla); } } inline bool jj_2_40(int xla) @@ -895,7 +895,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_40() || jj_done; - finally { jj_save(39, xla); } + { jj_save(39, xla); } } inline bool jj_2_41(int xla) @@ -903,7 +903,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_41() || jj_done; - finally { jj_save(40, xla); } + { jj_save(40, xla); } } inline bool jj_2_42(int xla) @@ -911,7 +911,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_42() || jj_done; - finally { jj_save(41, xla); } + { jj_save(41, xla); } } inline bool jj_2_43(int xla) @@ -919,7 +919,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_43() || jj_done; - finally { jj_save(42, xla); } + { jj_save(42, xla); } } inline bool jj_2_44(int xla) @@ -927,7 +927,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_44() || jj_done; - finally { jj_save(43, xla); } + { jj_save(43, xla); } } inline bool jj_2_45(int xla) @@ -935,7 +935,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_45() || jj_done; - finally { jj_save(44, xla); } + { jj_save(44, xla); } } inline bool jj_2_46(int xla) @@ -943,7 +943,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_46() || jj_done; - finally { jj_save(45, xla); } + { jj_save(45, xla); } } inline bool jj_2_47(int xla) @@ -951,7 +951,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_47() || jj_done; - finally { jj_save(46, xla); } + { jj_save(46, xla); } } inline bool jj_2_48(int xla) @@ -959,7 +959,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_48() || jj_done; - finally { jj_save(47, xla); } + { jj_save(47, xla); } } inline bool jj_2_49(int xla) @@ -967,7 +967,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_49() || jj_done; - finally { jj_save(48, xla); } + { jj_save(48, xla); } } inline bool jj_2_50(int xla) @@ -975,7 +975,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_50() || jj_done; - finally { jj_save(49, xla); } + { jj_save(49, xla); } } inline bool jj_2_51(int xla) @@ -983,7 +983,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_51() || jj_done; - finally { jj_save(50, xla); } + { jj_save(50, xla); } } inline bool jj_2_52(int xla) @@ -991,7 +991,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_52() || jj_done; - finally { jj_save(51, xla); } + { jj_save(51, xla); } } inline bool jj_2_53(int xla) @@ -999,7 +999,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_53() || jj_done; - finally { jj_save(52, xla); } + { jj_save(52, xla); } } inline bool jj_2_54(int xla) @@ -1007,7 +1007,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_54() || jj_done; - finally { jj_save(53, xla); } + { jj_save(53, xla); } } inline bool jj_2_55(int xla) @@ -1015,7 +1015,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_55() || jj_done; - finally { jj_save(54, xla); } + { jj_save(54, xla); } } inline bool jj_2_56(int xla) @@ -1023,7 +1023,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_56() || jj_done; - finally { jj_save(55, xla); } + { jj_save(55, xla); } } inline bool jj_2_57(int xla) @@ -1031,7 +1031,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_57() || jj_done; - finally { jj_save(56, xla); } + { jj_save(56, xla); } } inline bool jj_2_58(int xla) @@ -1039,7 +1039,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_58() || jj_done; - finally { jj_save(57, xla); } + { jj_save(57, xla); } } inline bool jj_2_59(int xla) @@ -1047,7 +1047,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_59() || jj_done; - finally { jj_save(58, xla); } + { jj_save(58, xla); } } inline bool jj_2_60(int xla) @@ -1055,7 +1055,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_60() || jj_done; - finally { jj_save(59, xla); } + { jj_save(59, xla); } } inline bool jj_2_61(int xla) @@ -1063,7 +1063,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_61() || jj_done; - finally { jj_save(60, xla); } + { jj_save(60, xla); } } inline bool jj_2_62(int xla) @@ -1071,7 +1071,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_62() || jj_done; - finally { jj_save(61, xla); } + { jj_save(61, xla); } } inline bool jj_2_63(int xla) @@ -1079,7 +1079,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_63() || jj_done; - finally { jj_save(62, xla); } + { jj_save(62, xla); } } inline bool jj_2_64(int xla) @@ -1087,7 +1087,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_64() || jj_done; - finally { jj_save(63, xla); } + { jj_save(63, xla); } } inline bool jj_2_65(int xla) @@ -1095,7 +1095,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_65() || jj_done; - finally { jj_save(64, xla); } + { jj_save(64, xla); } } inline bool jj_2_66(int xla) @@ -1103,7 +1103,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_66() || jj_done; - finally { jj_save(65, xla); } + { jj_save(65, xla); } } inline bool jj_2_67(int xla) @@ -1111,7 +1111,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_67() || jj_done; - finally { jj_save(66, xla); } + { jj_save(66, xla); } } inline bool jj_2_68(int xla) @@ -1119,7 +1119,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_68() || jj_done; - finally { jj_save(67, xla); } + { jj_save(67, xla); } } inline bool jj_2_69(int xla) @@ -1127,7 +1127,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_69() || jj_done; - finally { jj_save(68, xla); } + { jj_save(68, xla); } } inline bool jj_2_70(int xla) @@ -1135,7 +1135,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_70() || jj_done; - finally { jj_save(69, xla); } + { jj_save(69, xla); } } inline bool jj_2_71(int xla) @@ -1143,7 +1143,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_71() || jj_done; - finally { jj_save(70, xla); } + { jj_save(70, xla); } } inline bool jj_2_72(int xla) @@ -1151,7 +1151,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_72() || jj_done; - finally { jj_save(71, xla); } + { jj_save(71, xla); } } inline bool jj_2_73(int xla) @@ -1159,7 +1159,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_73() || jj_done; - finally { jj_save(72, xla); } + { jj_save(72, xla); } } inline bool jj_2_74(int xla) @@ -1167,7 +1167,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_74() || jj_done; - finally { jj_save(73, xla); } + { jj_save(73, xla); } } inline bool jj_2_75(int xla) @@ -1175,7 +1175,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_75() || jj_done; - finally { jj_save(74, xla); } + { jj_save(74, xla); } } inline bool jj_2_76(int xla) @@ -1183,7 +1183,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_76() || jj_done; - finally { jj_save(75, xla); } + { jj_save(75, xla); } } inline bool jj_2_77(int xla) @@ -1191,7 +1191,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_77() || jj_done; - finally { jj_save(76, xla); } + { jj_save(76, xla); } } inline bool jj_2_78(int xla) @@ -1199,7 +1199,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_78() || jj_done; - finally { jj_save(77, xla); } + { jj_save(77, xla); } } inline bool jj_2_79(int xla) @@ -1207,7 +1207,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_79() || jj_done; - finally { jj_save(78, xla); } + { jj_save(78, xla); } } inline bool jj_2_80(int xla) @@ -1215,7 +1215,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_80() || jj_done; - finally { jj_save(79, xla); } + { jj_save(79, xla); } } inline bool jj_2_81(int xla) @@ -1223,7 +1223,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_81() || jj_done; - finally { jj_save(80, xla); } + { jj_save(80, xla); } } inline bool jj_2_82(int xla) @@ -1231,7 +1231,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_82() || jj_done; - finally { jj_save(81, xla); } + { jj_save(81, xla); } } inline bool jj_2_83(int xla) @@ -1239,7 +1239,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_83() || jj_done; - finally { jj_save(82, xla); } + { jj_save(82, xla); } } inline bool jj_2_84(int xla) @@ -1247,7 +1247,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_84() || jj_done; - finally { jj_save(83, xla); } + { jj_save(83, xla); } } inline bool jj_2_85(int xla) @@ -1255,7 +1255,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_85() || jj_done; - finally { jj_save(84, xla); } + { jj_save(84, xla); } } inline bool jj_2_86(int xla) @@ -1263,7 +1263,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_86() || jj_done; - finally { jj_save(85, xla); } + { jj_save(85, xla); } } inline bool jj_2_87(int xla) @@ -1271,7 +1271,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_87() || jj_done; - finally { jj_save(86, xla); } + { jj_save(86, xla); } } inline bool jj_2_88(int xla) @@ -1279,7 +1279,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_88() || jj_done; - finally { jj_save(87, xla); } + { jj_save(87, xla); } } inline bool jj_2_89(int xla) @@ -1287,7 +1287,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_89() || jj_done; - finally { jj_save(88, xla); } + { jj_save(88, xla); } } inline bool jj_2_90(int xla) @@ -1295,7 +1295,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_90() || jj_done; - finally { jj_save(89, xla); } + { jj_save(89, xla); } } inline bool jj_2_91(int xla) @@ -1303,7 +1303,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_91() || jj_done; - finally { jj_save(90, xla); } + { jj_save(90, xla); } } inline bool jj_2_92(int xla) @@ -1311,7 +1311,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_92() || jj_done; - finally { jj_save(91, xla); } + { jj_save(91, xla); } } inline bool jj_2_93(int xla) @@ -1319,7 +1319,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_93() || jj_done; - finally { jj_save(92, xla); } + { jj_save(92, xla); } } inline bool jj_2_94(int xla) @@ -1327,7 +1327,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_94() || jj_done; - finally { jj_save(93, xla); } + { jj_save(93, xla); } } inline bool jj_2_95(int xla) @@ -1335,7 +1335,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_95() || jj_done; - finally { jj_save(94, xla); } + { jj_save(94, xla); } } inline bool jj_2_96(int xla) @@ -1343,7 +1343,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_96() || jj_done; - finally { jj_save(95, xla); } + { jj_save(95, xla); } } inline bool jj_2_97(int xla) @@ -1351,7 +1351,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_97() || jj_done; - finally { jj_save(96, xla); } + { jj_save(96, xla); } } inline bool jj_2_98(int xla) @@ -1359,7 +1359,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_98() || jj_done; - finally { jj_save(97, xla); } + { jj_save(97, xla); } } inline bool jj_2_99(int xla) @@ -1367,7 +1367,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_99() || jj_done; - finally { jj_save(98, xla); } + { jj_save(98, xla); } } inline bool jj_2_100(int xla) @@ -1375,7 +1375,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_100() || jj_done; - finally { jj_save(99, xla); } + { jj_save(99, xla); } } inline bool jj_2_101(int xla) @@ -1383,7 +1383,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_101() || jj_done; - finally { jj_save(100, xla); } + { jj_save(100, xla); } } inline bool jj_2_102(int xla) @@ -1391,7 +1391,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_102() || jj_done; - finally { jj_save(101, xla); } + { jj_save(101, xla); } } inline bool jj_2_103(int xla) @@ -1399,7 +1399,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_103() || jj_done; - finally { jj_save(102, xla); } + { jj_save(102, xla); } } inline bool jj_2_104(int xla) @@ -1407,7 +1407,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_104() || jj_done; - finally { jj_save(103, xla); } + { jj_save(103, xla); } } inline bool jj_2_105(int xla) @@ -1415,7 +1415,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_105() || jj_done; - finally { jj_save(104, xla); } + { jj_save(104, xla); } } inline bool jj_2_106(int xla) @@ -1423,7 +1423,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_106() || jj_done; - finally { jj_save(105, xla); } + { jj_save(105, xla); } } inline bool jj_2_107(int xla) @@ -1431,7 +1431,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_107() || jj_done; - finally { jj_save(106, xla); } + { jj_save(106, xla); } } inline bool jj_2_108(int xla) @@ -1439,7 +1439,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_108() || jj_done; - finally { jj_save(107, xla); } + { jj_save(107, xla); } } inline bool jj_2_109(int xla) @@ -1447,7 +1447,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_109() || jj_done; - finally { jj_save(108, xla); } + { jj_save(108, xla); } } inline bool jj_2_110(int xla) @@ -1455,7 +1455,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_110() || jj_done; - finally { jj_save(109, xla); } + { jj_save(109, xla); } } inline bool jj_2_111(int xla) @@ -1463,7 +1463,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_111() || jj_done; - finally { jj_save(110, xla); } + { jj_save(110, xla); } } inline bool jj_2_112(int xla) @@ -1471,7 +1471,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_112() || jj_done; - finally { jj_save(111, xla); } + { jj_save(111, xla); } } inline bool jj_2_113(int xla) @@ -1479,7 +1479,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_113() || jj_done; - finally { jj_save(112, xla); } + { jj_save(112, xla); } } inline bool jj_2_114(int xla) @@ -1487,7 +1487,7 @@ void parseInline(); jj_la = xla; jj_lastpos = jj_scanpos = token; jj_done = false; return !jj_3_114() || jj_done; - finally { jj_save(113, xla); } + { jj_save(113, xla); } } inline bool jj_3R_257() @@ -8849,39 +8849,46 @@ void parseInline(); return false; } - public: TokenManager *token_source; - public: CharStream *jj_input_stream; + +public: + TokenManager *token_source; + CharStream *jj_input_stream; /** Current token. */ - public: Token *token; + Token *token; /** Next token. */ - public: Token *jj_nt; - private: int jj_ntk; - private: JJCalls jj_2_rtns[115]; - private: bool jj_rescan; - private: int jj_gc; - private: Token *jj_scanpos, *jj_lastpos; - private: int jj_la; + Token *jj_nt; +private: + int jj_ntk; + JJCalls jj_2_rtns[115]; + bool jj_rescan; + int jj_gc; + Token *jj_scanpos, *jj_lastpos; + int jj_la; /** Whether we are looking ahead. */ - private: bool jj_lookingAhead; - private: bool jj_semLA; - private: int jj_gen; - private: int jj_la1[294]; - private: ErrorHandler *errorHandler; - private: bool errorHandlerCreated; - protected: bool hasError; - public: void setErrorHandler(ErrorHandler *eh) { + bool jj_lookingAhead; + bool jj_semLA; + int jj_gen; + int jj_la1[294]; + ErrorHandler *errorHandler; + bool errorHandlerCreated; +protected: + bool hasError; +public: + void setErrorHandler(ErrorHandler *eh) { if (errorHandlerCreated) delete errorHandler; errorHandler = eh; errorHandlerCreated = false; } - Token *head; - public: + Token *head; +public: VhdlParser(TokenManager *tm); - public: virtual ~VhdlParser(); + virtual ~VhdlParser(); void ReInit(TokenManager *tm); +void clear(); + Token * jj_consume_token(int kind); bool jj_scan_token(int kind); @@ -8891,24 +8898,29 @@ Token * getNextToken(); Token * getToken(int index); int jj_ntk_f(); - private: int jj_kind; +private: + int jj_kind; int **jj_expentries; int *jj_expentry; -void jj_add_error_token(int kind, int pos); + void jj_add_error_token(int kind, int pos); +protected: + /** Generate ParseException. */ + + virtual void parseError(); +private: + int trace_indent; + bool trace_enabled; -protected: virtual void parseError(); - private: int trace_indent; - private: bool trace_enabled; - /** Enable tracing. */ +public: -public: void enable_tracing(); + void enable_tracing(); -public: void disable_tracing(); + void disable_tracing(); -void jj_rescan_token(); + void jj_rescan_token(); -void jj_save(int index, int xla); + void jj_save(int index, int xla); typedef unsigned long long uint64; static Entry* current_root; @@ -8952,8 +8964,10 @@ static void mapLibPackage( Entry* root); static void createFlow(); static void error_skipto(int kind); static void oneLineComment(QCString qcs); -static void setMultCommentLine();private: bool jj_done; +static void setMultCommentLine(); +private: + bool jj_done; }; } } diff --git a/vhdlparser/VhdlParserConstants.h b/vhdlparser/VhdlParserConstants.h index 2f66b40..73f2a43 100644 --- a/vhdlparser/VhdlParserConstants.h +++ b/vhdlparser/VhdlParserConstants.h @@ -6,6 +6,7 @@ */ #ifndef VHDLPARSERCONSTANTS_H #define VHDLPARSERCONSTANTS_H +#include "JavaCC.h" namespace vhdl { namespace parser { diff --git a/vhdlparser/VhdlParserTokenManager.cc b/vhdlparser/VhdlParserTokenManager.cc index 1ddc623..ca09e99 100644 --- a/vhdlparser/VhdlParserTokenManager.cc +++ b/vhdlparser/VhdlParserTokenManager.cc @@ -1,5 +1,6 @@ /* VhdlParserTokenManager.cc */ -#include "./VhdlParserTokenManager.h" +#include "VhdlParserTokenManager.h" +#include "TokenMgrError.h" namespace vhdl { namespace parser { static const unsigned long long jjbitVec0[] = { @@ -2693,7 +2694,7 @@ int VhdlParserTokenManager::jjMoveNfa_0(int startState, int curPos){ if (curChar < 64) { unsigned long long l = 1ULL << curChar; - if (l == 1); + (void)l; do { switch(jjstateSet[--i]) @@ -3031,7 +3032,7 @@ int VhdlParserTokenManager::jjMoveNfa_0(int startState, int curPos){ else if (curChar < 128) { unsigned long long l = 1ULL << (curChar & 077); - if (l == 1); + (void)l; do { switch(jjstateSet[--i]) @@ -3245,7 +3246,7 @@ int VhdlParserTokenManager::jjMoveNfa_0(int startState, int curPos){ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) { jjAddStates(50, 51); } break; - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -3309,10 +3310,10 @@ bool VhdlParserTokenManager::jjCanMove_1(int hiByte, int i1, int i2, unsigned lo Token * VhdlParserTokenManager::jjFillToken(){ Token *t; JAVACC_STRING_TYPE curTokenImage; - int beginLine; - int endLine; - int beginColumn; - int endColumn; + int beginLine = -1; + int endLine = -1; + int beginColumn = -1; + int endColumn = -1; JAVACC_STRING_TYPE im = jjstrLiteralImages[jjmatchedKind]; curTokenImage = (im.length() == 0) ? input_stream->GetImage() : im; if (input_stream->getTrackLineColumn()) { @@ -3321,7 +3322,9 @@ Token * VhdlParserTokenManager::jjFillToken(){ endLine = input_stream->getEndLine(); endColumn = input_stream->getEndColumn(); } - t = Token::newToken(jjmatchedKind, curTokenImage); + t = Token::newToken(jjmatchedKind); + t->kind = jjmatchedKind; + t->image = curTokenImage; t->specialToken = NULL; t->next = NULL; @@ -3392,7 +3395,7 @@ Token * VhdlParserTokenManager::getNextToken(){ if (!EOFSeen) { error_after = curPos <= 1 ? EMPTY : input_stream->GetImage(); } - lexicalError(); + errorHandler->lexicalError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, this); } } @@ -3400,11 +3403,12 @@ Token * VhdlParserTokenManager::getNextToken(){ void VhdlParserTokenManager::SkipLexicalActions(Token *matchedToken){ switch(jjmatchedKind) { - case 3 : + case 3 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::lineCount(); break; - case 6 : + } + case 6 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); { QCString doc(image.data()); @@ -3417,15 +3421,18 @@ void VhdlParserTokenManager::SkipLexicalActions(Token *matchedToken){ ::vhdl::parser::VhdlParser::handleCommentBlock(image.data(),FALSE); ; } break; - case 7 : + } + case 7 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::handleFlowComment(image.data()); break; - case 8 : + } + case 8 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::lineCount(image.data()); break; - case 9 : + } + case 9 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); { QCString q(image.data()); @@ -3434,10 +3441,12 @@ void VhdlParserTokenManager::SkipLexicalActions(Token *matchedToken){ ::vhdl::parser::VhdlParser::handleCommentBlock(q.data(),TRUE);image.clear(); } break; - case 10 : + } + case 10 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::lineCount(image.data());image.clear(); break; + } default : break; } @@ -3446,105 +3455,128 @@ void VhdlParserTokenManager::SkipLexicalActions(Token *matchedToken){ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ switch(jjmatchedKind) { - case 17 : + case 17 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(ARCHITECTURE_T); break; - case 18 : + } + case 18 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(ARRAY_T); break; - case 22 : + } + case 22 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(ATTRIBUTE_T); break; - case 25 : + } + case 25 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(BODY_T); break; - case 28 : + } + case 28 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(COMPONENT_T); break; - case 30 : + } + case 30 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(CONFIGURATION_T); break; - case 31 : + } + case 31 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(CONSTANT_T); break; - case 32 : + } + case 32 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(CONTEXT_T); break; - case 39 : + } + case 39 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(END_T); break; - case 40 : + } + case 40 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(ENTITY_T); break; - case 43 : + } + case 43 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(FILE_T); break; - case 46 : + } + case 46 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(FUNCTION_T); break; - case 49 : + } + case 49 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(GROUP_T); break; - case 58 : + } + case 58 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); VhdlParser::setLineParsed(LIBRARY_T); break; - case 76 : + } + case 76 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(PACKAGE_T); break; - case 78 : + } + case 78 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(PORT_T); break; - case 80 : + } + case 80 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(PROCEDURE_T); break; - case 81 : + } + case 81 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(PROCESS_T); break; - case 86 : + } + case 86 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(RECORD_T); break; - case 100 : + } + case 100 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(SIGNAL_T); break; - case 107 : + } + case 107 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(SUBTYPE_T); break; - case 111 : + } + case 111 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(TYPE_T); break; - case 113 : + } + case 113 : { image.append(input_stream->GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); ::vhdl::parser::VhdlParser::setLineParsed(UNITS_T); break; + } default : break; } } /** Reinitialise parser. */ void VhdlParserTokenManager::ReInit(JAVACC_CHARSTREAM *stream, int lexState, VhdlParser *parserArg) { - if (input_stream) delete input_stream; + clear(); jjmatchedPos = jjnewStateCnt = 0; curLexState = lexState; input_stream = stream; @@ -3552,6 +3584,8 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ debugStream = stdout; // init SwitchTo(lexState); parser = parserArg; + errorHandler = new TokenManagerErrorHandler(); + errorHandlerCreated = true; } void VhdlParserTokenManager::ReInitRounds() { @@ -3563,10 +3597,17 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ /** Switch to specified lex state. */ void VhdlParserTokenManager::SwitchTo(int lexState) { - if (lexState >= 1 || lexState < 0) - assert(false); - //throw 1;//new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else + if (lexState >= 1 || lexState < 0) { + JAVACC_STRING_TYPE message; +#ifdef WIDE_CHAR + message += L"Error: Ignoring invalid lexical state : "; + message += lexState; message += L". State unchanged."; +#else + message += "Error: Ignoring invalid lexical state : "; + message += lexState; message += ". State unchanged."; +#endif + throw new TokenMgrError(message, INVALID_LEXICAL_STATE); + } else curLexState = lexState; } @@ -3574,12 +3615,23 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ VhdlParserTokenManager::VhdlParserTokenManager (JAVACC_CHARSTREAM *stream, int lexState, VhdlParser *parserArg) { input_stream = NULL; + errorHandlerCreated = false; ReInit(stream, lexState, parserArg); } // Destructor VhdlParserTokenManager::~VhdlParserTokenManager () { - if (input_stream) delete input_stream; + clear(); + } + + // clear + void VhdlParserTokenManager::clear() { + //Since input_stream was generated outside of TokenManager + //TokenManager should not take care of deleting it + //if (input_stream) delete input_stream; + if (errorHandlerCreated) delete errorHandler; } + + } } diff --git a/vhdlparser/VhdlParserTokenManager.h b/vhdlparser/VhdlParserTokenManager.h index 304cff3..f24c8e3 100644 --- a/vhdlparser/VhdlParserTokenManager.h +++ b/vhdlparser/VhdlParserTokenManager.h @@ -1,8 +1,10 @@ #ifndef VHDLPARSERTOKENMANAGER_H #define VHDLPARSERTOKENMANAGER_H +#include "stdio.h" #include "JavaCC.h" #include "CharStream.h" #include "Token.h" +#include "ErrorHandler.h" #include "TokenManager.h" #include "VhdlParserConstants.h" #include "VhdlParser.h" @@ -115,16 +117,27 @@ void TokenLexicalActions(Token *matchedToken); public: virtual ~VhdlParserTokenManager(); void ReInit(JAVACC_CHARSTREAM *stream, int lexState = 0, VhdlParser *parserArg = NULL); void SwitchTo(int lexState); + void clear(); const JAVACC_SIMPLE_STRING jjKindsForBitVector(int i, unsigned long long vec); const JAVACC_SIMPLE_STRING jjKindsForStateVector(int lexState, int vec[], int start, int end); - JAVACC_CHARSTREAM *input_stream; - int jjrounds[75]; - int jjstateSet[2 * 75]; - JAVACC_STRING_TYPE jjimage; - JAVACC_STRING_TYPE image; - int jjimageLen; - int lengthOfMatch; - JAVACC_CHAR_TYPE curChar; + JAVACC_CHARSTREAM* input_stream; + int jjrounds[75]; + int jjstateSet[2 * 75]; + JAVACC_STRING_TYPE jjimage; + JAVACC_STRING_TYPE image; + int jjimageLen; + int lengthOfMatch; + JAVACC_CHAR_TYPE curChar; + TokenManagerErrorHandler* errorHandler; + bool errorHandlerCreated; + +public: + void setErrorHandler(TokenManagerErrorHandler *eh) { + if (errorHandlerCreated && errorHandler != NULL) delete errorHandler; + errorHandler = eh; + errorHandlerCreated = false; + } + }; } } diff --git a/vhdlparser/vhdlstring.h b/vhdlparser/vhdlstring.h index 9403713..fde6ce4 100644 --- a/vhdlparser/vhdlstring.h +++ b/vhdlparser/vhdlstring.h @@ -100,8 +100,4 @@ class VhdlString int m_len; }; -extern VhdlString addUnicodeEscapes(VhdlString str); - -#define finally - #endif |