javacc-6.1.2.src.main.resources.templates.cpp.TokenManagerBoilerPlateMethods.template Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javacc Show documentation
Show all versions of javacc Show documentation
JavaCC is a parser/scanner generator for Java.
/** Reinitialise parser. */
void ${tokMgrClassName}::ReInit(JAVACC_CHARSTREAM *stream, int lexState, ${parserClassName} *parserArg) {
if (input_stream) delete input_stream;
jjmatchedPos = jjnewStateCnt = 0;
curLexState = lexState;
input_stream = stream;
ReInitRounds();
debugStream = stdout; // init
SwitchTo(lexState);
parser = parserArg;
errorHandler = new TokenManagerErrorHandler();
errorHandlerCreated = true;
}
void ${tokMgrClassName}::ReInitRounds() {
int i;
jjround = 0x80000001;
for (i = ${stateSetSize}; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Switch to specified lex state. */
void ${tokMgrClassName}::SwitchTo(int lexState) {
if (lexState >= ${lexStateNameLength} || lexState < 0)
assert(false);
//throw 1;//new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
/** Constructor. */
${tokMgrClassName}::${tokMgrClassName} (JAVACC_CHARSTREAM *stream, int lexState, ${parserClassName} *parserArg)
#if TOKEN_MANAGER_SUPER_CLASS
: ${TOKEN_MANAGER_SUPER_CLASS}()
#fi
{
input_stream = NULL;
ReInit(stream, lexState, parserArg);
}
// Destructor
${tokMgrClassName}::~${tokMgrClassName} () {
if (input_stream) delete input_stream;
if (errorHandlerCreated) delete errorHandler;
}