aboutsummaryrefslogtreecommitdiff
path: root/nomic.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-08-16 05:19:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-08-16 05:19:08 -0700
commitf6ab7587e1d036aa0a0c97ec0f82f66220ed3bdd (patch)
tree5fc36d7e102fe7aeb6a179493eab1d5c0191aab7 /nomic.moon
parent3dc68105e1699a8ef43857b5c26a4ad08cc4c5b9 (diff)
Much more cleanup. Now it's much easier to write mostly nomic code.
Diffstat (limited to 'nomic.moon')
-rw-r--r--nomic.moon8
1 files changed, 5 insertions, 3 deletions
diff --git a/nomic.moon b/nomic.moon
index e6af51a..21389a7 100644
--- a/nomic.moon
+++ b/nomic.moon
@@ -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}")