diff options
Diffstat (limited to 'src/parser.h')
-rw-r--r-- | src/parser.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/parser.h b/src/parser.h index 7ef6329..9908f31 100644 --- a/src/parser.h +++ b/src/parser.h @@ -113,11 +113,15 @@ protected: template <typename Type> class MicroStateMachine { protected: - typedef void *MicroState; - MicroState state; + /* label pointers */ + typedef const void *MicroState; + const MicroState StateStart; +#define MICROSTATE_START G_STMT_START { \ + if (MicroStateMachine::state != StateStart) \ + goto *MicroStateMachine::state; \ +} G_STMT_END -public: - MicroStateMachine() : state(NULL) {} + MicroState state; inline void set(MicroState next) @@ -126,10 +130,13 @@ public: undo.push_var(state) = next; } +public: + MicroStateMachine() : StateStart(NULL), state(StateStart) {} + virtual inline void reset(void) { - set(NULL); + set(StateStart); } virtual Type input(gchar chr) throw (State::Error) = 0; |