Added substring operator %x|start - stop|
This commit is contained in:
parent
a4c8e5ce65
commit
b1c6354464
@ -31,6 +31,10 @@ compile [..]
|
|||||||
# Indexing:
|
# Indexing:
|
||||||
compile [%obj'%key, %obj's %key, %obj -> %key] to: "(\(%obj as lua))[\(%key as lua)]"
|
compile [%obj'%key, %obj's %key, %obj -> %key] to: "(\(%obj as lua))[\(%key as lua)]"
|
||||||
|
|
||||||
|
# Substring
|
||||||
|
compile [%str |%start|] to: "\(%str as lua):sub(\(%start as lua), \(%start as lua))"
|
||||||
|
compile [%str |%start - %stop|] to: "\(%str as lua):sub(\(%start as lua), \(%stop as lua))"
|
||||||
|
|
||||||
# Variable assignment operator, and += type versions
|
# Variable assignment operator, and += type versions
|
||||||
compile [%var = %val] to code:
|
compile [%var = %val] to code:
|
||||||
lua> ".."
|
lua> ".."
|
||||||
|
@ -1,35 +1,24 @@
|
|||||||
require "lib/core.nom"
|
require "lib/core.nom"
|
||||||
require "lib/secrets.nom"
|
|
||||||
|
|
||||||
# Plurals
|
# Plurals
|
||||||
with secrets:
|
using:
|
||||||
lua do> ".."
|
<%endings> = (chain {x="es",c="es",s="es"} to "s")
|
||||||
local endings = setmetatable({x="es",c="es",s="es"}, {__index=function() return "s"; end});
|
<%plurals> = (chain {} to (: "\%\((<%endings>)->(%| -1|))"))
|
||||||
secrets.plurals = setmetatable({}, {__index=function(self,key)
|
<%singulars> = (..)
|
||||||
return key..endings[key:sub(-1)];
|
chain {} to:
|
||||||
end});
|
when:
|
||||||
secrets.singulars = setmetatable({}, {__index=function(self,key)
|
* (((%| -2|) == "es") and (=lua"rawget(\(<%endings>), \(%| -3|))")):
|
||||||
if key:sub(-2) == "es" and rawget(endings, key:sub(-3,-3)) then return key:sub(1,-3); end
|
%|1 - -3|
|
||||||
if key:sub(-1) == "s" then return key:sub(1,-2); end
|
* (%| -1| == "s"):
|
||||||
return key;
|
%|1 - -2|
|
||||||
end});
|
else: %
|
||||||
secrets.canonicals = setmetatable({}, {__index=function(self,key)
|
..do:
|
||||||
if key:sub(-1) == "s" then return secrets.singulars[key]; end
|
|
||||||
return key;
|
|
||||||
end});
|
|
||||||
|
|
||||||
rule [the plural of %singular is %plural] =:
|
rule [the plural of %singular is %plural] =:
|
||||||
(secret %plurals)->%singular = %plural
|
(<%plurals>)->%singular = %plural
|
||||||
(secret %singulars)->%plural = %singular
|
(<%singulars>)->%plural = %singular
|
||||||
(secret %canonicals)->%plural = %singular
|
|
||||||
|
|
||||||
rule [singular %plural] =:
|
rule [singular %plural] =:
|
||||||
%plural in (secret %singulars)
|
(<%singulars>)->%plural
|
||||||
|
|
||||||
rule [plural %singular] =:
|
rule [plural %singular] =:
|
||||||
%singular in (secret %plurals)
|
(<%plurals>)->%singular
|
||||||
|
|
||||||
rule [canonicalize %item_name] =:
|
|
||||||
%item_name in (secret %canonicals)
|
|
||||||
|
|
||||||
rule [rules that change plurals] =: ["the plural of % is %"]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user