mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Add while loop line and operator
This commit is contained in:
parent
f5382d2912
commit
48cabbf4c0
14 changed files with 500 additions and 61 deletions
|
|
@ -122,6 +122,23 @@ local function eval(state, exp)
|
|||
type = "nil",
|
||||
value = nil
|
||||
}
|
||||
-- while loop
|
||||
elseif exp.type == "~?" then
|
||||
local right, righte = eval(state, exp.right)
|
||||
if not right then return right, righte end
|
||||
local l = {}
|
||||
while truthy(right) do
|
||||
local left, lefte = eval(state, exp.left)
|
||||
if not left then return left, lefte end
|
||||
table.insert(l, left)
|
||||
-- next iteration
|
||||
right, righte = eval(state, exp.right)
|
||||
if not right then return right, righte end
|
||||
end
|
||||
return {
|
||||
type = "list",
|
||||
value = l
|
||||
}
|
||||
-- tag
|
||||
elseif exp.type == "#" then
|
||||
local right, righte = eval(state, exp.right)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue