aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-14 19:21:19 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-14 19:21:19 +0100
commitf63cf74a89027988aed16e2069c1ca8486c749b5 (patch)
treef14a3fc9fb5ebee253fafce3a564e2cba27442d9 /src/parser.h
parent6195aeba1899f50384b704b23ae2eea9c60c79a2 (diff)
downloadsciteco-f63cf74a89027988aed16e2069c1ca8486c749b5.tar.gz
hide some implementation details in MicroStateMachines
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h17
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;