in ragel/src/ragel/gogoto.cpp [587:734]
void GoGotoCodeGen::writeExec()
{
testEofUsed = false;
outLabelUsed = false;
out << " {" << endl;
if ( redFsm->anyRegCurStateRef() )
out << " var _ps " << INT() << " = 0" << endl;
if ( redFsm->anyToStateActions() || redFsm->anyRegActions()
|| redFsm->anyFromStateActions() )
{
out <<
" var _acts " << INT() << endl <<
" var _nacts " << UINT() << endl;
}
if ( redFsm->anyConditions() )
out << " var _widec " << WIDE_ALPH_TYPE() << endl;
out << endl;
if ( !noEnd ) {
testEofUsed = true;
out <<
" if " << P() << " == " << PE() << " {" << endl <<
" goto _test_eof" << endl <<
" }" << endl;
}
if ( redFsm->errState != 0 ) {
outLabelUsed = true;
out <<
" if " << vCS() << " == " << redFsm->errState->id << " {" << endl <<
" goto _out" << endl <<
" }" << endl;
}
out << "_resume:" << endl;
if ( redFsm->anyFromStateActions() ) {
out <<
" _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl <<
" _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl <<
" for ; _nacts > 0; _nacts-- {" << endl <<
" _acts++" << endl <<
" switch " << A() << "[_acts - 1]" << " {" << endl;
FROM_STATE_ACTION_SWITCH(2);
out <<
" }" << endl <<
" }" << endl <<
endl;
}
out <<
" switch " << vCS() << " {" << endl;
STATE_GOTOS(1);
out <<
" }" << endl <<
endl;
TRANSITIONS() <<
endl;
if ( redFsm->anyRegActions() )
EXEC_FUNCS() << endl;
out << "_again:" << endl;
if ( redFsm->anyToStateActions() ) {
out <<
" _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl <<
" _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl <<
" for ; _nacts > 0; _nacts-- {" << endl <<
" _acts++" << endl <<
" switch " << A() << "[_acts - 1]" << " {" << endl;
TO_STATE_ACTION_SWITCH(2);
out <<
" }" << endl <<
" }" << endl <<
endl;
}
if ( redFsm->errState != 0 ) {
outLabelUsed = true;
out <<
" if " << vCS() << " == " << redFsm->errState->id << " {" << endl <<
" goto _out" << endl <<
" }" << endl;
}
if ( !noEnd ) {
out <<
" if " << P() << "++; " << P() << " != " << PE() << " {" << endl <<
" goto _resume" << endl <<
" }" << endl;
}
else {
out <<
" " << P() << "++" << endl <<
" goto _resume" << endl;
}
if ( testEofUsed )
out << " _test_eof: {}" << endl;
if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
out <<
" if " << P() << " == " << vEOF() << " {" << endl;
if ( redFsm->anyEofTrans() ) {
out <<
" switch " << vCS() << " {" << endl;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st->eofTrans != 0 )
out <<
" case " << st->id << ":" << endl <<
" goto tr" << st->eofTrans->id << endl;
}
out <<
" }" << endl;
}
if ( redFsm->anyEofActions() ) {
out <<
" __acts := " << CAST(INT(), EA() + "[" + vCS() + "]") << endl <<
" __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl <<
" for ; __nacts > 0; __nacts-- {" << endl <<
" __acts++" << endl <<
" switch " << A() << "[__acts - 1]" << " {" << endl;
EOF_ACTION_SWITCH(3);
out <<
" }" << endl <<
" }" << endl;
}
out <<
" }" << endl <<
endl;
}
if ( outLabelUsed )
out << " _out: {}" << endl;
out << " }" << endl;
}