mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Remove -> operator
This commit is contained in:
parent
1eceadafc6
commit
18dd3ad6bd
6 changed files with 10 additions and 27 deletions
|
|
@ -43,7 +43,7 @@ local common = {
|
||||||
},
|
},
|
||||||
infixes = {
|
infixes = {
|
||||||
{ ";", 1 },
|
{ ";", 1 },
|
||||||
{ "#", 2 }, { "->", 2 }, { "~>", 2 },
|
{ "#", 2 }, { "->", 2 },
|
||||||
{ "~", 4 }, { "~?", 4 },
|
{ "~", 4 }, { "~?", 4 },
|
||||||
{ "|>", 5 }, { "&", 5 }, { "|", 5 },
|
{ "|>", 5 }, { "&", 5 }, { "|", 5 },
|
||||||
{ "==", 7 }, { "!=", 7 }, { ">=", 7 }, { "<=", 7 }, { "<", 7 }, { ">", 7 },
|
{ "==", 7 }, { "!=", 7 }, { ">=", 7 }, { "<=", 7 }, { "<", 7 }, { ">", 7 },
|
||||||
|
|
|
||||||
|
|
@ -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["_~>_"]
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,6 @@ local secondaries = {
|
||||||
r("infix.tuple"),
|
r("infix.tuple"),
|
||||||
r("infix.tag"),
|
r("infix.tag"),
|
||||||
r("infix.translate"),
|
r("infix.translate"),
|
||||||
r("infix.resume"),
|
|
||||||
-- 4
|
-- 4
|
||||||
r("infix.while"),
|
r("infix.while"),
|
||||||
r("infix.if"),
|
r("infix.if"),
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,18 @@ local ArgumentTuple, Boolean, Nil = ast.ArgumentTuple, ast.Boolean, ast.Nil
|
||||||
local resume_manager = require("anselme.state.resume_manager")
|
local resume_manager = require("anselme.state.resume_manager")
|
||||||
|
|
||||||
return {
|
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)",
|
"resume", "(function::closure, anchor::anchor)",
|
||||||
function(state, func, anchor)
|
function(state, func, anchor)
|
||||||
return func:resume(state, anchor)
|
return func:resume(state, anchor)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"resume", "(function::closure, anchor::nil)",
|
||||||
|
function(state, func)
|
||||||
|
return func:call(state, ArgumentTuple:new())
|
||||||
|
end
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"resuming", "()",
|
"resuming", "()",
|
||||||
function(state)
|
function(state)
|
||||||
|
|
|
||||||
2
ideas.md
2
ideas.md
|
|
@ -68,6 +68,8 @@ Syntax modifications:
|
||||||
Could interpret the left operand as a string when it is an identifier, like how _._ works.
|
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.
|
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.
|
Reduce the number of AST node types ; try to merge similar node and make simpler individuals nodes if possible by composing them.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
:f = $(anchor=())
|
:f = $(anchor=())
|
||||||
:x = 8
|
:x = 8
|
||||||
anchor ~>
|
($_)!resume(anchor)
|
||||||
|a
|
|a
|
||||||
| A |>
|
| A |>
|
||||||
| b
|
| b
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue