javacc-7.0.3.bin.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) {
clear();
jjmatchedPos = jjnewStateCnt = 0;
curLexState = lexState;
input_stream = stream;
ReInitRounds();
debugStream = stdout; // init
SwitchTo(lexState);
errorHandler = new TokenManagerErrorHandler();
}
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) {
JJString 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;
}
/** Constructor. */
${tokMgrClassName}::${tokMgrClassName} (JAVACC_CHARSTREAM *stream, int lexState)
#if TOKEN_MANAGER_SUPER_CLASS
: ${TOKEN_MANAGER_SUPER_CLASS}()
#fi
{
input_stream = nullptr;
ReInit(stream, lexState);
}
// Destructor
${tokMgrClassName}::~${tokMgrClassName} () {
clear();
}
// clear
void ${tokMgrClassName}::clear() {
//Since input_stream was generated outside of TokenManager
//TokenManager should not take care of deleting it
//if (input_stream) delete input_stream;
if (errorHandler) delete errorHandler, errorHandler = nullptr;
}