aboutsummaryrefslogtreecommitdiff
path: root/lib/metaprogramming.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-11 18:51:21 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-11 18:51:21 -0800
commite09f05a50cdb699029e8a4d5bafcfaade34157fd (patch)
treef216e71f7d7797706145f12349b48cd29d7c45ba /lib/metaprogramming.nom
parent06bf76f818382cdd33816073866f3cfd41609597 (diff)
Reshuffled all the library code into files that make more sense and
cleaned up some of the library code.
Diffstat (limited to 'lib/metaprogramming.nom')
-rw-r--r--lib/metaprogramming.nom20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/metaprogramming.nom b/lib/metaprogramming.nom
index a9c2ecf..55e9bea 100644
--- a/lib/metaprogramming.nom
+++ b/lib/metaprogramming.nom
@@ -176,3 +176,23 @@ parse [parse tree %code] as: nomsu "tree_to_str" [\%code]
parse [enable debugging] as: lua> "nomsu.debug = true"
parse [disable debugging] as: lua> "nomsu.debug = false"
+
+compile [say %str] to:
+ lua> ".."
+ if \%str.type == "Text" then
+ return "nomsu:writeln("..\(%str as lua)..")";
+ else
+ return "nomsu:writeln(nomsu:stringify("..\(%str as lua).."))";
+ end
+
+# Error functions
+compile [barf!] to: "error(nil, 0)"
+compile [barf %msg] to: "error(\(%msg as lua), 0)"
+compile [assume %condition] to: "assert(\(%condition as lua))"
+compile [assume %condition or barf %msg] to: "assert(\(%condition as lua), \(%msg as lua))"
+
+# Literals
+compile [yes] to: "true"
+compile [no] to: "false"
+compile [nothing, nil, null] to: "nil"
+