{
out << " {\n";
- if ( writeCS )
+ if ( !noCS )
out << "\t" << CS() << " = " << START() << ";\n";
/* If there are any calls, then the stack top needs initialization. */
string FsmCodeGen::DATA_PREFIX()
{
- if ( dataPrefix )
+ if ( !noPrefix )
return FSM_NAME() + "_";
return "";
}
if ( redFsm->startState != 0 )
STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
- if ( writeFirstFinal )
+ if ( !noFinal )
STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
- if ( writeErr )
+ if ( !noError )
STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
out << "\n";
" " << WIDE_ALPH_TYPE() << " _widec;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
if ( redFsm->anyConditions() )
out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
/* Advance and test buffer pos. */
if ( state->labelNeeded ) {
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _test_eof" << state->id << ";\n";
}
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st != redFsm->errState )
st->outNeeded = st->labelNeeded;
if ( redFsm->anyConditions() )
out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" }\n"
"\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
/* Advance and test buffer pos. */
if ( state->labelNeeded ) {
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _out" << state->id << ";\n";
"\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
outLabelUsed = true;
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
"static const int " << START() << " = " << START_STATE_ID() << ";\n"
"\n";
- if ( writeFirstFinal ) {
+ if ( !noFinal ) {
out <<
"static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
"\n";
}
- if ( writeErr ) {
+ if ( !noError ) {
out <<
"static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
"\n";
" {\n"
" int _stat = 0;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
* partition-switch exit from the last partition. */
out << "_reenter:\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _out;\n";
" if ( _stat )\n"
" goto _reenter;\n";
- if ( hasEnd )
+ if ( !noEnd )
out << " _out: {}\n";
out <<
}
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
st->outNeeded = st->labelNeeded;
}
" " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
"\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
{
out << " {\n";
- if ( writeCS )
+ if ( !noCS )
out << "\t" << CS() << " = " << START() << ";\n";
/* If there are any calls, then the stack top needs initialization. */
string CSharpFsmCodeGen::DATA_PREFIX()
{
- if ( dataPrefix )
+ if ( !noPrefix )
return FSM_NAME() + "_";
return "";
}
if ( redFsm->startState != 0 )
STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
- if ( writeFirstFinal )
+ if ( !noFinal )
STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
- if ( writeErr )
+ if ( !noError )
STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
out << "\n";
" " << WIDE_ALPH_TYPE() << " _widec;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
if ( redFsm->anyConditions() )
out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
/* Advance and test buffer pos. */
if ( state->labelNeeded ) {
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _test_eof" << state->id << ";\n";
}
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st != redFsm->errState )
st->outNeeded = st->labelNeeded;
if ( redFsm->anyConditions() )
out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" }\n"
"\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
/* Advance and test buffer pos. */
if ( state->labelNeeded ) {
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _out" << state->id << ";\n";
"\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
outLabelUsed = true;
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
"const int " << START() << " = " << START_STATE_ID() << ";\n"
"\n";
- if ( writeFirstFinal ) {
+ if ( !noFinal ) {
out <<
"const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
"\n";
}
- if ( writeErr ) {
+ if ( !noError ) {
out <<
"const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
"\n";
" {\n"
" int _stat = 0;\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
* partition-switch exit from the last partition. */
out << "_reenter:\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " == " << PE() << " )\n"
" goto _out;\n";
" if ( _stat )\n"
" goto _reenter;\n";
- if ( hasEnd )
+ if ( !noEnd )
out << " _out: {}\n";
out <<
}
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
st->outNeeded = st->labelNeeded;
}
"\n";
// " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
- if ( hasEnd ) {
+ if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _out;\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
dataExpr(0),
wantComplete(0),
hasLongestMatch(false),
- hasEnd(true),
- dataPrefix(true),
- writeFirstFinal(true),
- writeErr(true),
- writeCS(true)
+ noEnd(false),
+ noPrefix(false),
+ noFinal(false),
+ noError(false),
+ noCS(false)
{}
if ( strcmp( args[0], "data" ) == 0 ) {
for ( int i = 1; i < nargs; i++ ) {
if ( strcmp( args[i], "noerror" ) == 0 )
- writeErr = false;
+ noError = true;
else if ( strcmp( args[i], "noprefix" ) == 0 )
- dataPrefix = false;
+ noPrefix = true;
else if ( strcmp( args[i], "nofinal" ) == 0 )
- writeFirstFinal = false;
+ noFinal = true;
else {
source_warning(loc) << "unrecognized write option \"" <<
args[i] << "\"" << endl;
else if ( strcmp( args[0], "init" ) == 0 ) {
for ( int i = 1; i < nargs; i++ ) {
if ( strcmp( args[i], "nocs" ) == 0 )
- writeCS = false;
+ noCS = true;
else {
source_warning(loc) << "unrecognized write option \"" <<
args[i] << "\"" << endl;
else if ( strcmp( args[0], "exec" ) == 0 ) {
for ( int i = 1; i < nargs; i++ ) {
if ( strcmp( args[i], "noend" ) == 0 )
- hasEnd = false;
+ noEnd = true;
else {
source_warning(loc) << "unrecognized write option \"" <<
args[i] << "\"" << endl;
ExportList exportList;
/* Write options. */
- bool hasEnd;
- bool dataPrefix;
- bool writeFirstFinal;
- bool writeErr;
- bool writeCS;
+ bool noEnd;
+ bool noPrefix;
+ bool noFinal;
+ bool noError;
+ bool noCS;
void createMachine();
void initActionList( unsigned long length );
string JavaTabCodeGen::DATA_PREFIX()
{
- if ( dataPrefix )
+ if ( !noPrefix )
return FSM_NAME() + "_";
return "";
}
if ( redFsm->startState != 0 )
STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
- if ( writeFirstFinal )
+ if ( !noFinal )
STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
- if ( writeErr )
+ if ( !noError )
STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
out << "\n";
" switch ( _goto_targ ) {\n"
" case 0:\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( " << P() << " == " << PE() << " ) {\n"
" _goto_targ = " << _test_eof << ";\n"
" }\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " ) {\n"
" _goto_targ = " << _resume << ";\n"
{
out << " {\n";
- if ( writeCS )
+ if ( !noCS )
out << "\t" << CS() << " = " << START() << ";\n";
/* If there are any calls, then the stack top needs initialization. */
out << "\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
outLabelUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n";
" end" << "\n";
}
- if ( hasEnd ) {
+ if ( !noEnd ) {
out << " " << P() << " += 1\n"
" if ( " << P() << " != " << PE() << " )\n";
rbxGoto(out << " ", "_resume") << "\n" <<
string RubyCodeGen::DATA_PREFIX()
{
- if ( dataPrefix )
+ if ( !noPrefix )
return FSM_NAME() + "_";
return "";
}
if ( redFsm->startState != 0 )
STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
- if ( writeFirstFinal )
+ if ( !noFinal )
STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
- if ( writeErr )
+ if ( !noError )
STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
out << "\n";
out << " " << P() << " ||= 0\n";
- if ( hasEnd )
+ if ( !noEnd )
out << " " << PE() << " ||= " << DATA() << ".length\n";
- if ( writeCS )
+ if ( !noCS )
out << " " << CS() << " = " << START() << "\n";
/* If there are any calls, then the stack top needs initialization. */
" while true\n"
" if _goto_level <= 0\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " == " << PE() << "\n"
" _goto_level = _test_eof\n"
out << " " << P() << " += 1\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " != " << PE() << "\n"
" _goto_level = _resume\n"
" _trigger_goto = false\n"
" if _goto_level <= 0\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " == " << PE() << "\n"
" _goto_level = _test_eof\n"
out << " " << P() << " += 1\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " != " << PE() << "\n"
" _goto_level = _resume\n"
" while true\n"
" if _goto_level <= 0\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " == " << PE() << "\n"
" _goto_level = _test_eof\n"
out << " " << P() << " += 1\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " != " << PE() << "\n"
" _goto_level = _resume\n"
" _trigger_goto = false\n"
" if _goto_level <= 0\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " == " << PE() << "\n"
" _goto_level = _test_eof\n"
out << " " << P() << " += 1\n";
- if ( hasEnd ) {
+ if ( !noEnd ) {
out <<
" if " << P() << " != " << PE() << "\n"
" _goto_level = _resume\n"