Updating some more stuff.

This commit is contained in:
Bruce Hill 2017-12-14 13:57:53 -08:00
parent 10659d2f37
commit 1111210047
3 changed files with 22 additions and 22 deletions

View File

@ -4,19 +4,19 @@ require "lib/secrets.nom"
# Plurals # Plurals
with secrets: with secrets:
lua do> ".." lua do> ".."
|local endings = setmetatable({x="es",c="es",s="es"}, {__index=function() return "s"; end}); local endings = setmetatable({x="es",c="es",s="es"}, {__index=function() return "s"; end});
|secrets.plurals = setmetatable({}, {__index=function(self,key) secrets.plurals = setmetatable({}, {__index=function(self,key)
| return key..endings[key:sub(-1)]; return key..endings[key:sub(-1)];
|end}); end});
|secrets.singulars = setmetatable({}, {__index=function(self,key) secrets.singulars = setmetatable({}, {__index=function(self,key)
| if key:sub(-2) == "es" and rawget(endings, key:sub(-3,-3)) then return key:sub(1,-3); end if key:sub(-2) == "es" and rawget(endings, key:sub(-3,-3)) then return key:sub(1,-3); end
| if key:sub(-1) == "s" then return key:sub(1,-2); end if key:sub(-1) == "s" then return key:sub(1,-2); end
| return key; return key;
|end}); end});
|secrets.canonicals = setmetatable({}, {__index=function(self,key) secrets.canonicals = setmetatable({}, {__index=function(self,key)
| if key:sub(-1) == "s" then return secrets.singulars[key]; end if key:sub(-1) == "s" then return secrets.singulars[key]; end
| return key; return key;
|end}); end});
rule [the plural of %singular is %plural] =: rule [the plural of %singular is %plural] =:
(secret %plurals)->%singular = %plural (secret %plurals)->%singular = %plural

View File

@ -1,10 +1,10 @@
require "lib/core.nom" require "lib/core.nom"
compile [with secrets %block] to code: ".." compile [with secrets %block] to code: ".."
|do; do
| local secrets = {}; local secrets = {};
| \(%block as lua statements) \(%block as lua statements)
|end; end
# Access the lua variable that should be within scope # Access the lua variable that should be within scope
compile [secrets] to: "secrets" compile [secrets] to: "secrets"

View File

@ -4,10 +4,10 @@ require "lib/metaprogramming.nom"
rule [test tree %generated == %expected] =: rule [test tree %generated == %expected] =:
if (%generated != %expected): if (%generated != %expected):
error ".." error ".."
|Test Failed! Test Failed!
|Expected: Expected:
|\(%expected) \(%expected)
|But got: But got:
|\(%generated) \(%generated)
parse [test %code yields %expected] as: parse [test %code yields %expected] as:
test tree (nomsu "tree_to_str" [\%code]) == %expected test tree (nomsu "tree_to_str" [\%code]) == %expected