mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Operator priority cleanup
This commit is contained in:
parent
68a109391f
commit
ba1824a904
3 changed files with 9 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ local common = {
|
|||
-- list of operators and their priority that are handled through regular function calls & can be overloaded/etc. by the user
|
||||
regular_operators = {
|
||||
prefixes = {
|
||||
{ ">", 3.1 }, -- just above _=_
|
||||
{ ">", 4 }, -- just above _=_
|
||||
{ "!", 11 },
|
||||
{ "-", 11 },
|
||||
{ "*", 11 },
|
||||
|
|
@ -44,9 +44,9 @@ local common = {
|
|||
{ ";", 1 },
|
||||
{ "#", 2 }, { "->", 2 },
|
||||
{ "|>", 5 }, { "&", 5 }, { "|", 5 },
|
||||
{ "==", 7 }, { "!=", 7 }, { ">=", 7 }, { "<=", 7 }, { "<", 7 }, { ">", 7 },
|
||||
{ "+", 8 }, { "-", 8 },
|
||||
{ "//", 9 }, { "/", 9 }, { "*", 9 }, { "%", 9 },
|
||||
{ "==", 6 }, { "!=", 6 }, { ">=", 6 }, { "<=", 6 }, { "<", 6 }, { ">", 6 },
|
||||
{ "+", 7 }, { "-", 7 },
|
||||
{ "//", 8 }, { "/", 8 }, { "*", 8 }, { "%", 8 },
|
||||
{ "^", 10 },
|
||||
{ "::", 11 },
|
||||
{ ".", 14 },
|
||||
|
|
@ -59,8 +59,9 @@ local common = {
|
|||
["$_"] = 2,
|
||||
["_,_"] = 2,
|
||||
["_=_"] = 3,
|
||||
["_implicit*_"] = 9, -- just aboce _*_
|
||||
["_!_"] = 12,
|
||||
["_()"] = 13
|
||||
["_()"] = 13 -- just above _!
|
||||
-- generated at run-time for regular operators
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTu
|
|||
return infix {
|
||||
operator = "*",
|
||||
identifier = "_*_",
|
||||
priority = operator_priority["_*_"]+.1, -- just above / so 1/2x gives 1/(2x)
|
||||
priority = operator_priority["_implicit*_"],
|
||||
|
||||
match = function(self, str, current_priority, primary)
|
||||
return self.priority > current_priority and identifier:match(str)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue