From 2d8ba76ddaf6634f285d0a81ee42d5ee77d084cf Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Tue, 28 Dec 2021 18:23:45 +0000 Subject: 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 --- src/libfsm/asm.cc | 2 +- src/libfsm/goto.cc | 4 ++-- src/libfsm/ipgoto.cc | 2 +- src/libfsm/tabbreak.cc | 2 +- src/libfsm/tabgoto.cc | 2 +- src/libfsm/tabvar.cc | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/libfsm/asm.cc b/src/libfsm/asm.cc index ecfe1c0f..db084d6e 100644 --- a/src/libfsm/asm.cc +++ b/src/libfsm/asm.cc @@ -1160,7 +1160,7 @@ void AsmCodeGen::NFA_PUSH( RedStateAp *st ) void AsmCodeGen::STATE_GOTOS() { - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { /* Writing code above state gotos. */ diff --git a/src/libfsm/goto.cc b/src/libfsm/goto.cc index 610f44d1..04d381d9 100644 --- a/src/libfsm/goto.cc +++ b/src/libfsm/goto.cc @@ -368,7 +368,7 @@ void Goto::FROM_STATE_ACTION_EMIT( RedStateAp *state ) std::ostream &Goto::STATE_CASES() { - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { /* Writing code above state gotos. */ @@ -881,7 +881,7 @@ void Goto::writeExec() out << EMIT_LABEL( _resume ); /* Do we break out on no more input. */ - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); if ( !noEnd ) { if ( eof ) { out << diff --git a/src/libfsm/ipgoto.cc b/src/libfsm/ipgoto.cc index 3718ea91..5748ad72 100644 --- a/src/libfsm/ipgoto.cc +++ b/src/libfsm/ipgoto.cc @@ -452,7 +452,7 @@ void IpGoto::NFA_PUSH_ST( RedStateAp *state ) std::ostream &IpGoto::STATE_GOTOS() { - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { IN_TRANS_ACTIONS( st ); diff --git a/src/libfsm/tabbreak.cc b/src/libfsm/tabbreak.cc index ee82cc0c..87f7c690 100644 --- a/src/libfsm/tabbreak.cc +++ b/src/libfsm/tabbreak.cc @@ -215,7 +215,7 @@ void TabBreak::writeExec() out << BREAK_LABEL( _resume ); /* Do we break out on no more input. */ - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); if ( !noEnd ) { if ( eof ) { out << diff --git a/src/libfsm/tabgoto.cc b/src/libfsm/tabgoto.cc index ca90cb9d..8179d4b5 100644 --- a/src/libfsm/tabgoto.cc +++ b/src/libfsm/tabgoto.cc @@ -185,7 +185,7 @@ void TabGoto::writeExec() out << EMIT_LABEL( _resume ); /* Do we break out on no more input. */ - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); if ( !noEnd ) { if ( eof ) { out << diff --git a/src/libfsm/tabvar.cc b/src/libfsm/tabvar.cc index 02bd7b55..1b0ae824 100644 --- a/src/libfsm/tabvar.cc +++ b/src/libfsm/tabvar.cc @@ -161,7 +161,7 @@ void TabVar::writeExec() out << BREAK_LABEL( _resume ); /* Do we break out on no more input. */ - bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates(); + bool eof = redFsm->anyEofActivity() || redFsm->anyNfaStates() || redFsm->anyFromStateActions(); if ( !noEnd ) { if ( eof ) { out << -- cgit v1.2.1