in ragel/src/ragel/gotable.cpp [807:977]
void GoTabCodeGen::writeExec()
{
testEofUsed = false;
outLabelUsed = false;
out <<
" {" << endl <<
" var _klen " << INT() << endl;
if ( redFsm->anyRegCurStateRef() )
out << " var _ps " << INT() << endl;
out <<
" var _trans " << INT() << endl;
if ( redFsm->anyConditions() )
out << " var _widec " << WIDE_ALPH_TYPE() << endl;
if ( redFsm->anyToStateActions() || redFsm->anyRegActions()
|| redFsm->anyFromStateActions() )
{
out <<
" var _acts " << INT() << endl <<
" var _nacts " << UINT() << endl;
}
out <<
" var _keys " << INT() << 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;
}
if ( redFsm->anyConditions() )
COND_TRANSLATE();
LOCATE_TRANS();
out << "_match:" << endl;
if ( useIndicies )
out << " _trans = " << CAST(INT(), I() + "[_trans]") << endl;
if ( redFsm->anyEofTrans() )
out << "_eof_trans:" << endl;
if ( redFsm->anyRegCurStateRef() )
out << " _ps = " << vCS() << endl;
out <<
" " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << endl;
if ( redFsm->anyRegActions() ) {
out <<
" if " << TA() << "[_trans] == 0 {" << endl <<
" goto _again" << endl <<
" }" << endl <<
endl <<
" _acts = " << CAST(INT(), TA() + "[_trans]") << endl <<
" _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl <<
" for ; _nacts > 0; _nacts-- {" << endl <<
" _acts++" << endl <<
" switch " << A() << "[_acts-1]" << " {" << endl;
ACTION_SWITCH(2);
out <<
" }" << endl <<
" }" << endl << endl;
}
if ( redFsm->anyRegActions() || redFsm->anyActionGotos() ||
redFsm->anyActionCalls() || redFsm->anyActionRets() )
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 <<
" " << P() << "++" << endl <<
" if " << 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 <<
" if " << ET() << "[" << vCS() << "] > 0 {" << endl <<
" _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl <<
" goto _eof_trans" << endl <<
" }" << endl;
}
if ( redFsm->anyEofActions() ) {
out <<
" __acts := " << 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;
}