diff options
author | Adrian Thurston <thurston@complang.org> | 2011-07-26 05:32:36 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-07-26 05:32:36 +0000 |
commit | 76b4982d242845593fee5676585533ad720a40c9 (patch) | |
tree | 9721cd31a9409738275d6347f103701db2babccf /ragel | |
parent | 1d4b23d64db888153310068b8111993765f3dc9f (diff) | |
download | colm-76b4982d242845593fee5676585533ad720a40c9.tar.gz |
Some work on making checkErrorTrans work with condition lists. refs #306.
Diffstat (limited to 'ragel')
-rw-r--r-- | ragel/fsmbase.cpp | 49 | ||||
-rw-r--r-- | ragel/fsmgraph.h | 1 |
2 files changed, 48 insertions, 2 deletions
diff --git a/ragel/fsmbase.cpp b/ragel/fsmbase.cpp index b1b753b8..fed27878 100644 --- a/ragel/fsmbase.cpp +++ b/ragel/fsmbase.cpp @@ -560,12 +560,35 @@ void FsmAp::setStateNumbers( int base ) state->alg.stateNum = base++; } - -bool FsmAp::checkErrTrans( StateAp *state, TransAp *trans ) +bool FsmAp::checkErrTrans( StateAp *state, CondAp *trans ) { std::cout << "FIXME: " << __PRETTY_FUNCTION__ << std::endl; /* Might go directly to error state. */ + if ( trans->toState == 0 ) + return true; + +// FIXME: look for gaps. +// if ( trans->prev == 0 ) { +// /* If this is the first transition. */ +// if ( keyOps->minKey < trans->lowKey ) +// return true; +// } +// else { +// /* Not the first transition. Compare against the prev. */ +// TransAp *prev = trans->prev; +// Key nextKey = prev->highKey; +// nextKey.increment(); +// if ( nextKey < trans->lowKey ) +// return true; +// } + + return false; +} + +bool FsmAp::checkErrTrans( StateAp *state, TransAp *trans ) +{ + /* Might go directly to error state. */ if ( trans->ctList.head->toState == 0 ) return true; @@ -582,6 +605,28 @@ bool FsmAp::checkErrTrans( StateAp *state, TransAp *trans ) if ( nextKey < trans->lowKey ) return true; } + + if ( trans->condSpace == 0 ) { + /* If there is no cond space then we are just dealing with a single + * transtion. (optionally) */ + if ( trans->ctList.length() == 0 ) + return true; + else { + CondAp *cond = trans->ctList.head; + if ( cond->toState == 0 ) + return true; + } + } + else { + /* Need to check destination, as well as for gaps. Use the condSpace to + * determine where to end. */ + for ( CondTransList::Iter cti = trans->ctList; cti.lte(); cti++ ) { + bool res = checkErrTrans( state, cti ); + if ( res ) + return true; + } + } + return false; } diff --git a/ragel/fsmgraph.h b/ragel/fsmgraph.h index 8b94b73a..de7dea3e 100644 --- a/ragel/fsmgraph.h +++ b/ragel/fsmgraph.h @@ -1589,6 +1589,7 @@ struct FsmAp /* Returns true if there is a transtion (either explicit or by a gap) to * the error state. */ bool checkErrTrans( StateAp *state, TransAp *trans ); + bool checkErrTrans( StateAp *state, CondAp *trans ); bool checkErrTransFinish( StateAp *state ); bool hasErrorTrans(); |