Misc. cleanups.

This commit is contained in:
Bruce Hill 2017-10-19 18:56:42 -07:00
parent 09cb00e106
commit 9f61e7f90d
3 changed files with 11 additions and 8 deletions

View File

@ -159,6 +159,8 @@ rule [%items sorted by %key] =:
%copy = (% for all %items)
sort %copy by %key
%copy
rule [unique %items] =:
keys in (dict from entries ([%,yes] for all %items))
# Metatable stuff
compile [counter] to: "setmetatable({}, {__index=function() return 0; end})"

View File

@ -1,7 +1,7 @@
require "lib/metaprogramming.nom"
# Moonscript!
parse [moonscript block %moonscript_code] as:
parse [moonscript do> %moonscript_code] as:
lua do> ".."
|local parse, compile = require('moonscript.parse'), require('moonscript.compile');
|local moon_code = nomsu:tree_to_value(vars.moonscript_code, vars);
@ -15,7 +15,7 @@ parse [moonscript block %moonscript_code] as:
|end;
|return "do\\n"..lua_code.."\\nend";
parse [moonscript %moonscript_code] as:
parse [moonscript> %moonscript_code] as:
lua do> ".."
|local parse, compile = require('moonscript.parse'), require('moonscript.compile');
|local moon_code = nomsu:tree_to_value(vars.moonscript_code, vars);

View File

@ -5,15 +5,16 @@ require "lib/collections.nom"
# Permission functions
rule [standardize rules %rules] =:
if (=lua "type(vars.rules) == 'string'"): %rules = [%rules]
if ((type of %rules) == "string"): %rules = [%rules]
(nomsu "get_stub" [%]) for all %rules
%set = []
%result = []
for %rule in %rules:
%stub = (nomsu "get_stub" [%rule])
%aliases = (((nomsu's "defs")->%stub)->"aliases")
for all %aliases: %set -> % = (yes)
keys in %set
%def = ((nomsu's "defs")->%stub)
assert %def "Undefined rule: \(%stub)"
%aliases = (%def's "aliases")
for all %aliases: add % to %result
unique %result
rule [restrict %rules to within %elite_rules] =:
%rules = (standardize rules %rules)