1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-28 00:59:31 +00:00

ArgumentTuple cleanup

This commit is contained in:
Étienne Fildadut 2023-12-23 00:22:00 +01:00
parent fe351b5ca4
commit ffadc0dd69
12 changed files with 88 additions and 105 deletions

View file

@ -2,10 +2,8 @@
local primary = require("parser.expression.primary.primary")
local StringInterpolation = require("ast.StringInterpolation")
local ast = require("ast")
local String = ast.String
local String, StringInterpolation = ast.String, ast.StringInterpolation
local expression_to_ast = require("parser.expression.to_ast")

View file

@ -32,7 +32,7 @@ return primary {
if type_check:match(rem, 0, nil_val) then
local exp
exp, rem = type_check:parse(source, rem, nil, 0, nil_val)
type_check_exp = exp.arguments.list[2]
type_check_exp = exp.arguments.positional[2]
end
return ident:to_symbol{ constant = constant, persistent = persistent, exported = exported, type_check = type_check_exp }:set_source(source), rem

View file

@ -18,7 +18,7 @@ return infix {
end,
build_ast = function(self, left, right)
left.arguments:set_assignment(right)
left.arguments:add_assignment(right)
return Call:new(left.func, left.arguments) -- recreate Call since we modified left.arguments
end,
}

View file

@ -19,8 +19,7 @@ return infix {
build_ast = function(self, left, right)
if Call:is(right) then
right.arguments:insert_positional(1, left)
return right
return Call:new(right.func, right.arguments:with_first_argument(left))
else
return Call:new(right, ArgumentTuple:new(left))
end

View file

@ -27,11 +27,11 @@ return secondary {
exp = Tuple:new(exp)
end
for i, v in ipairs(exp.list) do
for _, v in ipairs(exp.list) do
if Assignment:is(v) then
args:set_named(v.identifier, v.expression)
args:add_named(v.identifier, v.expression)
else
args:set_positional(i, v)
args:add_positional(v)
end
end