aboutsummaryrefslogtreecommitdiff
path: root/nomic.moon
diff options
context:
space:
mode:
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}")