in ragel/src/ragel/cstable.cpp [936:1109]
void CSharpTabCodeGen::writeExec()
{
testEofUsed = false;
outLabelUsed = false;
initVarTypes();
out <<
" {\n"
" " << klenType << " _klen";
if ( redFsm->anyRegCurStateRef() )
out << ", _ps";
out <<
";\n"
" " << transType << " _trans;\n";
if ( redFsm->anyConditions() )
out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
if ( redFsm->anyToStateActions() || redFsm->anyRegActions()
|| redFsm->anyFromStateActions() )
{
out <<
" int _acts;\n"
" int _nacts;\n";
}
out <<
" " << keysType << " _keys;\n"
"\n";
// " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
if ( !noEnd ) {
testEofUsed = true;
out <<
" if ( " << P() << " == " << PE() << " )\n"
" goto _test_eof;\n";
}
if ( redFsm->errState != 0 ) {
outLabelUsed = true;
out <<
" if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
" goto _out;\n";
}
out << "_resume:\n";
if ( redFsm->anyFromStateActions() ) {
out <<
" _acts = " << FSA() << "[" + vCS() + "]" << ";\n"
" _nacts = " << A() << "[_acts++];\n"
" while ( _nacts-- > 0 ) {\n"
" switch ( " << A() << "[_acts++] ) {\n";
FROM_STATE_ACTION_SWITCH();
SWITCH_DEFAULT() <<
" }\n"
" }\n"
"\n";
}
if ( redFsm->anyConditions() )
COND_TRANSLATE();
LOCATE_TRANS();
out << "_match:\n";
if ( useIndicies )
out << " _trans = " << CAST(transType) << I() << "[_trans];\n";
if ( redFsm->anyEofTrans() )
out << "_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"
" goto _again;\n"
"\n"
" _acts = " << TA() << "[_trans]" << ";\n"
" _nacts = " << A() << "[_acts++];\n"
" while ( _nacts-- > 0 )\n {\n"
" switch ( " << A() << "[_acts++] )\n {\n";
ACTION_SWITCH();
SWITCH_DEFAULT() <<
" }\n"
" }\n"
"\n";
}
if ( redFsm->anyRegActions() || redFsm->anyActionGotos() ||
redFsm->anyActionCalls() || redFsm->anyActionRets() )
out << "_again:\n";
if ( redFsm->anyToStateActions() ) {
out <<
" _acts = " << TSA() << "[" << vCS() << "]" << ";\n"
" _nacts = " << A() << "[_acts++];\n"
" while ( _nacts-- > 0 ) {\n"
" switch ( " << A() << "[_acts++] ) {\n";
TO_STATE_ACTION_SWITCH();
SWITCH_DEFAULT() <<
" }\n"
" }\n"
"\n";
}
if ( redFsm->errState != 0 ) {
outLabelUsed = true;
out <<
" if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
" goto _out;\n";
}
if ( !noEnd ) {
out <<
" if ( ++" << P() << " != " << PE() << " )\n"
" goto _resume;\n";
}
else {
out <<
" " << P() << " += 1;\n"
" goto _resume;\n";
}
if ( testEofUsed )
out << " _test_eof: {}\n";
if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
out <<
" if ( " << P() << " == " << vEOF() << " )\n"
" {\n";
if ( redFsm->anyEofTrans() ) {
out <<
" if ( " << ET() << "[" << vCS() << "] > 0 ) {\n"
" _trans = " << CAST(transType) << " (" << ET() <<
"[" << vCS() << "] - 1);\n"
" goto _eof_trans;\n"
" }\n";
}
if ( redFsm->anyEofActions() ) {
out <<
" int __acts = " <<
EA() << "[" << vCS() << "]" << ";\n"
" int __nacts = " <<
A() << "[__acts++];\n"
" while ( __nacts-- > 0 ) {\n"
" switch ( " << A() << "[__acts++] ) {\n";
EOF_ACTION_SWITCH();
SWITCH_DEFAULT() <<
" }\n"
" }\n";
}
out <<
" }\n"
"\n";
}
if ( outLabelUsed )
out << " _out: {}\n";
out << " }\n";
}