diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-16 05:01:35 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-16 05:01:35 -0700 |
| commit | 3dc68105e1699a8ef43857b5c26a4ad08cc4c5b9 (patch) | |
| tree | 38113c90caca57afeef3156fc02c6984a6d11e25 /nomic.moon | |
| parent | 4c584bd2edda45f374a16e6bf909bd9d256701da (diff) | |
Cleaned up some and added rule modifying rule.
Diffstat (limited to 'nomic.moon')
| -rw-r--r-- | nomic.moon | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -5,12 +5,6 @@ type = moon.type export __DEBUG__ -invocation_def = [[ - name <- {| {chunk} (" " {chunk})* |} -> semicolonify - chunk <- ({"$"} %S+) / ({%S+}) -]] -invocation_def = re.compile(invocation_def, {semicolonify: (bits) -> table.concat(bits, ";")}) - as_value = (x, globals, locals)-> assert (globals and locals), "Shit's fucked" @@ -115,9 +109,14 @@ class Rule unless thunk error("failed to parse!") @fn = (globals,locals)-> thunk\run(globals, locals) - else + elseif type(action) == Thunk + @body_str = tostring(action) + @fn = (globals,locals)-> action\run(globals, locals) + elseif type(action) == 'function' @body_str = "<lua function>" @fn = action + else + error("Invalid action type: #{type(action)}") eq = (x,y)-> if #x != #y then return false @@ -166,4 +165,8 @@ run = (game, str)-> return ret return ()-> - {rules:{}, relations:{}, :run, :def} + game = {rules:{}, relations:{}, :run, :def} + game\def [[$invocations := $body]], (locals)=> + game\def locals.invocations, locals.body + return nil + return game |
