Skip to content

Commit

Permalink
Switched back to version 6.2 of JavaCC for VHDL parser generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Jan 3, 2015
1 parent d75455e commit 088896f
Show file tree
Hide file tree
Showing 16 changed files with 481 additions and 373 deletions.
4 changes: 2 additions & 2 deletions vhdlparser/CharStream.cc
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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) */
190 changes: 92 additions & 98 deletions vhdlparser/CharStream.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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; }

/**
Expand All @@ -47,57 +47,56 @@ 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;
}


/**
* Returns the next character from the selected input. The method
* 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();
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

Expand All @@ -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) */
44 changes: 40 additions & 4 deletions vhdlparser/ErrorHandler.h
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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) */
6 changes: 2 additions & 4 deletions vhdlparser/ParseException.cc
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -183,4 +181,4 @@ namespace parser {

}
}
/* JavaCC - OriginalChecksum=99d488e13335cf377284c90700f070ed (do not edit this line) */
/* JavaCC - OriginalChecksum=9f6af8fd72f5fe3e4210cf02acbd8387 (do not edit this line) */
Loading

0 comments on commit 088896f

Please sign in to comment.