mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Fix conflict between comparison & compound operators
Everyone makes mistakes.
This commit is contained in:
parent
a7f2362199
commit
8eb4bd5ac5
2 changed files with 23 additions and 19 deletions
|
|
@ -5,31 +5,35 @@ local assignment = require("parser.expression.secondary.infix.assignment")
|
||||||
local assignment_call = require("parser.expression.secondary.infix.assignment_call")
|
local assignment_call = require("parser.expression.secondary.infix.assignment_call")
|
||||||
|
|
||||||
local infixes = require("common").regular_operators.infixes
|
local infixes = require("common").regular_operators.infixes
|
||||||
|
local operator_priority = require("common").operator_priority
|
||||||
|
|
||||||
local generated = {}
|
local generated = {}
|
||||||
|
|
||||||
for _, infix in ipairs(infixes) do
|
for _, infix in ipairs(infixes) do
|
||||||
local operator = infix[1].."="
|
local compound_operator = infix[1].."="
|
||||||
local identifier = "_=_"
|
local identifier = "_=_"
|
||||||
local infix_identifier = "_"..infix[1].."_"
|
local infix_identifier = "_"..infix[1].."_"
|
||||||
|
|
||||||
table.insert(generated, assignment {
|
-- avoid a lot of unecessary trouble with <= & friends. why would you ever want to use i <= 7 as i = i < 7 anyway.
|
||||||
operator = operator,
|
if not operator_priority["_"..compound_operator.."_"] then
|
||||||
identifier = identifier,
|
table.insert(generated, assignment {
|
||||||
build_ast = function(self, left, right)
|
operator = compound_operator,
|
||||||
right = Call:new(Identifier:new(infix_identifier), ArgumentTuple:new(left, right))
|
identifier = identifier,
|
||||||
return assignment.build_ast(self, left, right)
|
build_ast = function(self, left, right)
|
||||||
end
|
right = Call:new(Identifier:new(infix_identifier), ArgumentTuple:new(left, right))
|
||||||
})
|
return assignment.build_ast(self, left, right)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
table.insert(generated, assignment_call {
|
table.insert(generated, assignment_call {
|
||||||
operator = operator,
|
operator = compound_operator,
|
||||||
identifier = identifier,
|
identifier = identifier,
|
||||||
build_ast = function(self, left, right)
|
build_ast = function(self, left, right)
|
||||||
right = Call:new(Identifier:new(infix_identifier), ArgumentTuple:new(left, right))
|
right = Call:new(Identifier:new(infix_identifier), ArgumentTuple:new(left, right))
|
||||||
return assignment_call.build_ast(self, left, right)
|
return assignment_call.build_ast(self, left, right)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return generated
|
return generated
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@ local secondaries = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add generated assignement+infix operator combos, before the rest
|
-- add generated assignement+infix operator combos, before the rest
|
||||||
local assignment_operators = r("infix.assignment_with_infix")
|
local compound_assignments = r("infix.assignment_with_infix")
|
||||||
for i, op in ipairs(assignment_operators) do
|
for i, op in ipairs(compound_assignments) do
|
||||||
table.insert(secondaries, i, op)
|
table.insert(secondaries, i, op)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue