Added pattern matching for text, and comprehension versions of that and
file walking.
This commit is contained in:
parent
cb1c3106f8
commit
85ef9534e3
@ -26,6 +26,24 @@ action [lines in %text, lines of %text]
|
||||
end
|
||||
return result
|
||||
|
||||
compile [for %match where %text matches %patt %body] to
|
||||
Lua ".."
|
||||
for \(%match as lua expr) in \(%text as lua expr):gmatch(\(%patt as lua expr)) do
|
||||
\(%body as lua statements)
|
||||
\(compile as: === next %match ===)
|
||||
end
|
||||
\(compile as: === stop %match ===)
|
||||
|
||||
compile [%expr for %match where %text matches %patt] to
|
||||
Lua value ".."
|
||||
(function()
|
||||
local ret = list{}
|
||||
for \(%match as lua expr) in \(%text as lua expr):gmatch(\(%patt as lua expr)) do
|
||||
ret[#ret+1] = \(%expr as lua statements)
|
||||
end
|
||||
return ret
|
||||
end)()
|
||||
|
||||
# Text literals
|
||||
lua> ".."
|
||||
do
|
||||
|
10
lib/os.nom
10
lib/os.nom
@ -23,6 +23,16 @@ compile [for file %f in %path %body] to
|
||||
end
|
||||
\(compile as: === stop %f ===)
|
||||
|
||||
compile [%expr for file %f in %path] to
|
||||
Lua value ".."
|
||||
(function()
|
||||
local ret = list{}
|
||||
for \(%f as lua expr) in files.walk(\(%path as lua expr)) do
|
||||
ret[#ret+1] = \(%expr as lua statements)
|
||||
end
|
||||
return ret
|
||||
end)()
|
||||
|
||||
action [write to file %filename %text, to file %filename write %text]
|
||||
lua> ".."
|
||||
local file = io.open(\%filename, 'w')
|
||||
|
Loading…
Reference in New Issue
Block a user