in ragel/src/ragel/rubyftable.cpp [362:527]
void RubyFTabCodeGen::writeExec()
{
out <<
"begin\n"
" testEof = false\n"
" _klen, _trans, _keys";
if ( redFsm->anyRegCurStateRef() )
out << ", _ps";
if ( redFsm->anyConditions() )
out << ", _widec";
out << " = nil\n";
out <<
" _goto_level = 0\n"
" _resume = 10\n"
" _eof_trans = 15\n"
" _again = 20\n"
" _test_eof = 30\n"
" _out = 40\n";
out <<
" while true\n"
" if _goto_level <= 0\n";
if ( !noEnd ) {
out <<
" if " << P() << " == " << PE() << "\n"
" _goto_level = _test_eof\n"
" next\n"
" end\n";
}
if ( redFsm->errState != 0 ) {
out <<
" if " << vCS() << " == " << redFsm->errState->id << "\n"
" _goto_level = _out\n"
" next\n"
" end\n";
}
/* The resume label. */
out <<
" end\n"
" if _goto_level <= _resume\n";
if ( redFsm->anyFromStateActions() ) {
out <<
" case " << FSA() << "[" << vCS() << "] \n";
FROM_STATE_ACTION_SWITCH() <<
" end # from state action switch \n"
"\n";
}
if ( redFsm->anyConditions() )
COND_TRANSLATE();
LOCATE_TRANS();
if ( useIndicies )
out << " _trans = " << I() << "[_trans];\n";
if ( redFsm->anyEofTrans() ) {
out <<
" end\n"
" if _goto_level <= _eof_trans\n";
}
if ( redFsm->anyRegCurStateRef() )
out << " _ps = " << vCS() << ";\n";
out <<
" " << vCS() << " = " << TT() << "[_trans];\n"
"\n";
if ( redFsm->anyRegActions() ) {
out <<
" if " << TA() << "[_trans] != 0\n"
"\n"
" case " << TA() << "[_trans] \n";
ACTION_SWITCH() <<
" end # action switch \n"
" end\n"
"\n";
}
/* The again label. */
out <<
" end\n"
" if _goto_level <= _again\n";
if ( redFsm->anyToStateActions() ) {
out <<
" case " << TSA() << "[" << vCS() << "] \n";
TO_STATE_ACTION_SWITCH() <<
" end\n"
"\n";
}
if ( redFsm->errState != 0 ) {
out <<
" if " << vCS() << " == " << redFsm->errState->id << "\n"
" _goto_level = _out\n"
" next\n"
" end\n";
}
out << " " << P() << " += 1\n";
if ( !noEnd ) {
out <<
" if " << P() << " != " << PE() << "\n"
" _goto_level = _resume\n"
" next\n"
" end\n";
}
else {
out <<
" _goto_level = _resume\n"
" next\n";
}
/* The test eof label. */
out <<
" end\n"
" if _goto_level <= _test_eof\n";
if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
out <<
" if " << P() << " == " << vEOF() << "\n";
if ( redFsm->anyEofTrans() ) {
out <<
" if " << ET() << "[" << vCS() << "] > 0\n"
" _trans = " << ET() << "[" << vCS() << "] - 1;\n"
" _goto_level = _eof_trans\n"
" next;\n"
" end\n";
}
if ( redFsm->anyEofActions() ) {
out <<
" begin\n"
" case ( " << EA() << "[" << vCS() << "] )\n";
EOF_ACTION_SWITCH() <<
" end\n"
" end\n";
}
out <<
" end\n"
"\n";
}
out <<
" end\n"
" if _goto_level <= _out\n"
" break\n"
" end\n"
"end\n";
/* Wrapping the execute block. */
out << " end\n";
}