From c96f0e86982fdfe692ac8afe4f93c311278f4143 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Tue, 20 Sep 2011 09:00:19 -0400 Subject: [PATCH] start to think about event model --- marmots_todo.txt | 4 ++-- scripting.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/marmots_todo.txt b/marmots_todo.txt index 149114f..e6ff8e6 100644 --- a/marmots_todo.txt +++ b/marmots_todo.txt @@ -1,3 +1,5 @@ +- listen to many events at once (required for vm, very useful to do away with awkward oob pattern most places) + debugging output: - decorate classes which we expect not to be in the output, warn if we persist them - @@ -8,5 +10,3 @@ TRef -- we do not want to hold on to references -- actually in our case we don't want to save GameWBs at all, we want to persist boards lazily (except for metadata?) -Cldg - -- well, this sucks :P guid? attach to game? \ No newline at end of file diff --git a/scripting.py b/scripting.py index 5923e5a..003b061 100644 --- a/scripting.py +++ b/scripting.py @@ -437,6 +437,20 @@ class SyntSet(SyntDesc): if not isinstance(val, Fail): vm.Log(vm.vars.Set(self.lvalue.syntVar, vm.Pop(), self)) +class SyntWhen(SyntDesc): + desc = [["When"], " ", (SyntEvent, 1), ":", (SyntBlock, 2)] + +class SyntEvent(SyntDesc): + rgclsSyntEvent = [] + desc = [[" "]] + @classmethod + def RgsyntReplace(cls, syntChild, st, rtype): + for clsSyntEvent in cls.rgclsSyntEvent: + if clsSyntEvent.StForTypein().lower().startswith(st.lower()): + yield clsSyntEvent.SyntDefault() + for synt in SyntExpr.RgsyntReplace(syntChild, st, rtype): + yield synt + #debug @RegStmt class SyntPrint(SyntDesc):