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

Remove -> operator

This commit is contained in:
Étienne Fildadut 2024-01-01 14:11:18 +01:00
parent 1eceadafc6
commit 18dd3ad6bd
6 changed files with 10 additions and 27 deletions

View file

@ -43,7 +43,7 @@ local common = {
},
infixes = {
{ ";", 1 },
{ "#", 2 }, { "->", 2 }, { "~>", 2 },
{ "#", 2 }, { "->", 2 },
{ "~", 4 }, { "~?", 4 },
{ "|>", 5 }, { "&", 5 }, { "|", 5 },
{ "==", 7 }, { "!=", 7 }, { ">=", 7 }, { "<=", 7 }, { "<", 7 }, { ">", 7 },

View file

@ -1,9 +0,0 @@
local infix_quote_right = require("anselme.parser.expression.secondary.infix.infix_quote_right")
local operator_priority = require("anselme.common").operator_priority
return infix_quote_right {
operator = "~>",
identifier = "_~>_",
priority = operator_priority["_~>_"]
}

View file

@ -12,7 +12,6 @@ local secondaries = {
r("infix.tuple"),
r("infix.tag"),
r("infix.translate"),
r("infix.resume"),
-- 4
r("infix.while"),
r("infix.if"),

View file

@ -4,27 +4,18 @@ local ArgumentTuple, Boolean, Nil = ast.ArgumentTuple, ast.Boolean, ast.Nil
local resume_manager = require("anselme.state.resume_manager")
return {
{
"_~>_", "(anchor::anchor, quote)",
function(state, anchor, quote)
resume_manager:push(state, anchor)
local r = quote:call(state, ArgumentTuple:new())
resume_manager:pop(state)
return r
end
},
{
"_~>_", "(anchor::nil, quote)",
function(state, anchor, quote)
return quote:call(state, ArgumentTuple:new())
end
},
{
"resume", "(function::closure, anchor::anchor)",
function(state, func, anchor)
return func:resume(state, anchor)
end
},
{
"resume", "(function::closure, anchor::nil)",
function(state, func)
return func:call(state, ArgumentTuple:new())
end
},
{
"resuming", "()",
function(state)

View file

@ -68,6 +68,8 @@ Syntax modifications:
Could interpret the left operand as a string when it is an identifier, like how _._ works.
Would feel good to have less nodes. But because we can doesn't mean we should. Also Assignment is reused in a few other places.
- remove operators if possible, i'd like to avoid the code looking like a bunch of sigils
---
Reduce the number of AST node types ; try to merge similar node and make simpler individuals nodes if possible by composing them.

View file

@ -8,7 +8,7 @@
:f = $(anchor=())
:x = 8
anchor ~>
($_)!resume(anchor)
|a
| A |>
| b