mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Merge behavior of : and = into single = operator for pairs; add assignment with _._ operator in function references
This commit is contained in:
parent
48cabbf4c0
commit
88157b04b9
19 changed files with 104 additions and 38 deletions
|
|
@ -42,7 +42,7 @@ common = {
|
|||
"_!=_", "_==_", "_>=_", "_<=_", "_<_", "_>_",
|
||||
"_+_", "_-_",
|
||||
"_*_", "_//_", "_/_", "_%_",
|
||||
"_::_", "_:_",
|
||||
"_::_", "_=_",
|
||||
"_^_",
|
||||
"_._", "_!_",
|
||||
-- suffix unop
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ local binops_prio = {
|
|||
[5] = { "!=", "==", ">=", "<=", "<", ">" },
|
||||
[6] = { "+", "-" },
|
||||
[7] = { "*", "//", "/", "%" },
|
||||
[8] = { "::", ":" },
|
||||
[8] = { "::", "=" },
|
||||
[9] = {}, -- unary operators
|
||||
[10] = { "^" },
|
||||
[11] = { ".", "!" },
|
||||
[12] = {}
|
||||
}
|
||||
local pair_priority = 8
|
||||
-- unop priority
|
||||
local prefix_unops_prio = {
|
||||
[1] = {},
|
||||
|
|
@ -129,9 +130,9 @@ local function expression(s, state, namespace, current_priority, operating_on)
|
|||
local name, r = s:match("^("..identifier_pattern..")(.-)$")
|
||||
name = format_identifier(name)
|
||||
-- string:value pair shorthand using =
|
||||
if r:match("^=[^=]") then
|
||||
if r:match("^=[^=]") and pair_priority > current_priority then
|
||||
local val
|
||||
val, r = expression(r:match("^=(.*)$"), state, namespace, 9)
|
||||
val, r = expression(r:match("^=(.*)$"), state, namespace, pair_priority)
|
||||
if not val then return val, r end
|
||||
local args = {
|
||||
type = "list",
|
||||
|
|
@ -142,7 +143,7 @@ local function expression(s, state, namespace, current_priority, operating_on)
|
|||
right = val
|
||||
}
|
||||
-- find compatible variant
|
||||
local variant, err = find_function(state, namespace, "_:_", args, true)
|
||||
local variant, err = find_function(state, namespace, "_=_", args, true)
|
||||
if not variant then return variant, err end
|
||||
return expression(r, state, namespace, current_priority, variant)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue