From f6ab7587e1d036aa0a0c97ec0f82f66220ed3bdd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 Aug 2017 05:19:08 -0700 Subject: Much more cleanup. Now it's much easier to write mostly nomic code. --- nomic.moon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nomic.moon') 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}") -- cgit v1.2.3