cdipgoto.cpp (ragel-6.9) | : | cdipgoto.cpp (ragel-6.10) | ||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
*/ | */ | |||
#include "ragel.h" | #include "ragel.h" | |||
#include "cdipgoto.h" | #include "cdipgoto.h" | |||
#include "redfsm.h" | #include "redfsm.h" | |||
#include "gendata.h" | #include "gendata.h" | |||
#include "bstmap.h" | #include "bstmap.h" | |||
bool IpGotoCodeGen::useAgainLabel() | bool IpGotoCodeGen::useAgainLabel() | |||
{ | { | |||
return redFsm->anyRegActionRets() || | return redFsm->anyActionRets() || | |||
redFsm->anyRegActionByValControl() || | redFsm->anyActionByValControl() || | |||
redFsm->anyRegNextStmt(); | redFsm->anyRegNextStmt(); | |||
} | } | |||
void IpGotoCodeGen::EOF_CHECK( ostream &ret, int gotoDest ) | ||||
{ | ||||
ret << | ||||
" if ( " << P() << " == " << PE() << " )\n" | ||||
" goto _test_eof" << gotoDest << ";\n"; | ||||
testEofUsed = true; | ||||
} | ||||
void IpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) | void IpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) | |||
{ | { | |||
ret << "{" << CTRL_FLOW() << "goto st" << gotoDest << ";}"; | ret << "{"; | |||
if ( inFinish && !noEnd ) | ||||
EOF_CHECK( ret, gotoDest ); | ||||
ret << CTRL_FLOW() << "goto st" << gotoDest << ";"; | ||||
ret << "}"; | ||||
} | } | |||
void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFini sh ) | void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFini sh ) | |||
{ | { | |||
if ( prePushExpr != 0 ) { | if ( prePushExpr != 0 ) { | |||
ret << "{"; | ret << "{"; | |||
INLINE_LIST( ret, prePushExpr, 0, false, false ); | INLINE_LIST( ret, prePushExpr, 0, false, false ); | |||
} | } | |||
ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << | ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << ";"; | |||
"; " << CTRL_FLOW() << "goto st" << callDest << ";}"; | ||||
if ( inFinish && !noEnd ) | ||||
EOF_CHECK( ret, callDest ); | ||||
ret << CTRL_FLOW() << "goto st" << callDest << ";"; | ||||
ret << "}"; | ||||
if ( prePushExpr != 0 ) | if ( prePushExpr != 0 ) | |||
ret << "}"; | ret << "}"; | |||
} | } | |||
void IpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targStat e, bool inFinish ) | void IpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targStat e, bool inFinish ) | |||
{ | { | |||
if ( prePushExpr != 0 ) { | if ( prePushExpr != 0 ) { | |||
ret << "{"; | ret << "{"; | |||
INLINE_LIST( ret, prePushExpr, 0, false, false ); | INLINE_LIST( ret, prePushExpr, 0, false, false ); | |||
} | } | |||
ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << "; " << | ret << "{"; | |||
vCS() << " = ("; | ||||
ret << STACK() << "[" << TOP() << "++] = " << targState << "; " << vCS() | ||||
<< " = ("; | ||||
INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); | INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); | |||
ret << "); " << CTRL_FLOW() << "goto _again;}"; | ret << ");"; | |||
if ( inFinish && !noEnd ) | ||||
FsmCodeGen::EOF_CHECK( ret ); | ||||
ret << CTRL_FLOW() << "goto _again;"; | ||||
ret << "}"; | ||||
if ( prePushExpr != 0 ) | if ( prePushExpr != 0 ) | |||
ret << "}"; | ret << "}"; | |||
} | } | |||
void IpGotoCodeGen::RET( ostream &ret, bool inFinish ) | void IpGotoCodeGen::RET( ostream &ret, bool inFinish ) | |||
{ | { | |||
ret << "{" << vCS() << " = " << STACK() << "[--" << TOP() << "];"; | ret << "{" << vCS() << " = " << STACK() << "[--" << TOP() << "];"; | |||
if ( postPopExpr != 0 ) { | if ( postPopExpr != 0 ) { | |||
ret << "{"; | ret << "{"; | |||
INLINE_LIST( ret, postPopExpr, 0, false, false ); | INLINE_LIST( ret, postPopExpr, 0, false, false ); | |||
ret << "}"; | ret << "}"; | |||
} | } | |||
ret << CTRL_FLOW() << "goto _again;}"; | if ( inFinish && !noEnd ) | |||
FsmCodeGen::EOF_CHECK( ret ); | ||||
ret << CTRL_FLOW() << "goto _again;"; | ||||
ret << "}"; | ||||
} | } | |||
void IpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinis h ) | void IpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinis h ) | |||
{ | { | |||
ret << "{" << vCS() << " = ("; | ret << "{"; | |||
ret << vCS() << " = ("; | ||||
INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); | INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); | |||
ret << "); " << CTRL_FLOW() << "goto _again;}"; | ret << ");"; | |||
if ( inFinish && !noEnd ) | ||||
FsmCodeGen::EOF_CHECK( ret ); | ||||
ret << CTRL_FLOW() << "goto _again;"; | ||||
ret << "}"; | ||||
} | } | |||
void IpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) | void IpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) | |||
{ | { | |||
ret << vCS() << " = " << nextDest << ";"; | ret << vCS() << " = " << nextDest << ";"; | |||
} | } | |||
void IpGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinis h ) | void IpGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinis h ) | |||
{ | { | |||
ret << vCS() << " = ("; | ret << vCS() << " = ("; | |||
skipping to change at line 352 | skipping to change at line 396 | |||
/* Need labels for states that have goto or calls in acti on code | /* Need labels for states that have goto or calls in acti on code | |||
* invoked on characters (ie, not from out action code). */ | * invoked on characters (ie, not from out action code). */ | |||
if ( trans->action != 0 ) { | if ( trans->action != 0 ) { | |||
/* Loop the actions. */ | /* Loop the actions. */ | |||
for ( GenActionTable::Iter act = trans->action->k ey; act.lte(); act++ ) { | for ( GenActionTable::Iter act = trans->action->k ey; act.lte(); act++ ) { | |||
/* Get the action and walk it's tree. */ | /* Get the action and walk it's tree. */ | |||
setLabelsNeeded( act->value->inlineList ) ; | setLabelsNeeded( act->value->inlineList ) ; | |||
} | } | |||
} | } | |||
} | } | |||
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) | ||||
{ | ||||
if ( st->eofAction != 0 ) { | ||||
for ( GenActionTable::Iter item = st->eofAction-> | ||||
key; item.lte(); item++ ) | ||||
setLabelsNeeded( item->value->inlineList | ||||
); | ||||
} | ||||
} | ||||
} | } | |||
if ( !noEnd ) { | if ( !noEnd ) { | |||
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { | for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { | |||
if ( st != redFsm->errState ) | if ( st != redFsm->errState ) | |||
st->outNeeded = st->labelNeeded; | st->outNeeded = st->labelNeeded; | |||
} | } | |||
} | } | |||
} | } | |||
End of changes. 10 change blocks. | ||||
11 lines changed or deleted | 65 lines changed or added |