diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-02-14 19:21:19 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-02-14 19:21:19 +0100 |
commit | f63cf74a89027988aed16e2069c1ca8486c749b5 (patch) | |
tree | f14a3fc9fb5ebee253fafce3a564e2cba27442d9 /src/parser.h | |
parent | 6195aeba1899f50384b704b23ae2eea9c60c79a2 (diff) | |
download | sciteco-f63cf74a89027988aed16e2069c1ca8486c749b5.tar.gz |
hide some implementation details in MicroStateMachines
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; |