Skip to content

Commit 2d8ba76

Browse files
generate a check for EOF if there are from-state actions
From-state actions now execute on EOF, but we don't check for their presence when deciding if we should test against EOF. This led to from-state actions executing only if other conditions necessitating EOF-testing are present. Added the check. refs adrian-thurston/ragel#80
1 parent be2c9cf commit 2d8ba76

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/libfsm/asm.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ void AsmCodeGen::NFA_PUSH( RedStateAp *st )
11601160

11611161
void AsmCodeGen::STATE_GOTOS()
11621162
{
1163-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
1163+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
11641164

11651165
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
11661166
/* Writing code above state gotos. */

src/libfsm/goto.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void Goto::FROM_STATE_ACTION_EMIT( RedStateAp *state )
368368

369369
std::ostream &Goto::STATE_CASES()
370370
{
371-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
371+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
372372

373373
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
374374
/* Writing code above state gotos. */
@@ -881,7 +881,7 @@ void Goto::writeExec()
881881
out << EMIT_LABEL( _resume );
882882

883883
/* Do we break out on no more input. */
884-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
884+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
885885
if ( !noEnd ) {
886886
if ( eof ) {
887887
out <<

src/libfsm/ipgoto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void IpGoto::NFA_PUSH_ST( RedStateAp *state )
452452

453453
std::ostream &IpGoto::STATE_GOTOS()
454454
{
455-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
455+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
456456

457457
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
458458
IN_TRANS_ACTIONS( st );

src/libfsm/tabbreak.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void TabBreak::writeExec()
215215
out << BREAK_LABEL( _resume );
216216

217217
/* Do we break out on no more input. */
218-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
218+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
219219
if ( !noEnd ) {
220220
if ( eof ) {
221221
out <<

src/libfsm/tabgoto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void TabGoto::writeExec()
185185
out << EMIT_LABEL( _resume );
186186

187187
/* Do we break out on no more input. */
188-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
188+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
189189
if ( !noEnd ) {
190190
if ( eof ) {
191191
out <<

src/libfsm/tabvar.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void TabVar::writeExec()
161161
out << BREAK_LABEL( _resume );
162162

163163
/* Do we break out on no more input. */
164-
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates();
164+
bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions();
165165
if ( !noEnd ) {
166166
if ( eof ) {
167167
out <<

0 commit comments

Comments
 (0)