From e09f05a50cdb699029e8a4d5bafcfaade34157fd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 11 Jan 2018 18:51:21 -0800 Subject: Reshuffled all the library code into files that make more sense and cleaned up some of the library code. --- lib/metaprogramming.nom | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/metaprogramming.nom') 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" + -- cgit v1.2.3