diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-16 05:19:08 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-16 05:19:08 -0700 |
| commit | f6ab7587e1d036aa0a0c97ec0f82f66220ed3bdd (patch) | |
| tree | 5fc36d7e102fe7aeb6a179493eab1d5c0191aab7 /nomic.moon | |
| parent | 3dc68105e1699a8ef43857b5c26a4ad08cc4c5b9 (diff) | |
Much more cleanup. Now it's much easier to write mostly nomic code.
Diffstat (limited to 'nomic.moon')
| -rw-r--r-- | nomic.moon | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -82,7 +82,7 @@ class Thunk lingo = [[ actions <- {| (%nl " "*)* ((" "*) action ((%nl " "*)+ action)*)? (%nl " "*)* |} -> Thunk action <- {| token (" "+ token)* " "* |} -> Action - token <- expression / ({(!"[" [^ {}()$])+} -> Word) + token <- expression / ({(!"[" !%nl [^ {}()$])+} -> Word) expression <- number / string / list / variable / thunk / subexpression number <- ('-'? [0-9]+ ("." [0-9]+)?) -> tonumber string <- ('"' {(("\\" .) / [^"])*} '"') -> tostring @@ -151,10 +151,12 @@ def = (game, invocation, action)-> rule = Rule(invocations, action) for invocation in *rule.invocations game.rules[invocation] = rule - print rule + if __DEBUG__ + print rule run = (game, str)-> - print(">> #{str\gsub("\n", "\n.. ")}") + if __DEBUG__ + print(">> #{str\gsub("\n", "\n.. ")}") thunk = lingo\match str unless thunk error("failed to parse nomic:\n#{str}") |
