Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.4 #5

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
641dd8b
customizable func ast
gnlow Sep 7, 2023
8ed82b7
Update deno.yml
gnlow Sep 8, 2023
70db8c4
add: `arrow` (only match literals)
gnlow Sep 8, 2023
e069188
add: add,sub,mul,div
gnlow Sep 8, 2023
61bbfe3
nested defs
gnlow Sep 8, 2023
d714ff1
add: arrow capture (no type check yet)
gnlow Sep 9, 2023
ab52e58
seperate file
gnlow Sep 9, 2023
456de8b
feat: multiple match
gnlow Sep 9, 2023
9cbd9ba
refactor: `call` match with `expr`
gnlow Sep 9, 2023
22bd3cb
refactor
gnlow Sep 9, 2023
de8b631
feat: automatic lifting for junction
gnlow Sep 9, 2023
4fe3295
export util/f
gnlow Sep 11, 2023
1ee91eb
refactor: `def` as normal binExpr
gnlow Sep 11, 2023
ab8427c
feat: more expandable funcs
gnlow Sep 16, 2023
d2db9ea
use external importMap
gnlow Sep 16, 2023
bdafa9f
wtf
gnlow Sep 16, 2023
5651142
wtff
gnlow Sep 16, 2023
a9cdf42
whyyyyyyyyyyy
gnlow Sep 17, 2023
3b60ed9
delete importMap
gnlow Sep 17, 2023
8d683aa
ast helper function for testing
gnlow Sep 23, 2023
872a752
ast helper - `or`
gnlow Sep 23, 2023
f3c8376
ast helper - `join`
gnlow Sep 23, 2023
fc35f94
ast helper - `join` (2)
gnlow Sep 23, 2023
1ef1cee
ast helper - `ref`
gnlow Sep 23, 2023
a88d344
ast helper - `def`
gnlow Sep 23, 2023
cce4d8b
ast helper - `def` (2)
gnlow Sep 23, 2023
ae51aec
ast helper - `and`
gnlow Sep 23, 2023
48e4ce5
ast helper - `arrow`
gnlow Sep 23, 2023
7f0818a
ast helper - `capture`
gnlow Sep 23, 2023
ddac902
ast helper - `mul`
gnlow Sep 23, 2023
49a3879
ast helper - etc.
gnlow Sep 23, 2023
c4c0296
Update expand.test.ts
gnlow Sep 23, 2023
1fe5a4e
impl: and(or(....), ...)
gnlow Sep 23, 2023
ceb63a0
feat: guard
gnlow Sep 25, 2023
77d3a59
feat: Typed Capture
gnlow Sep 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ast helper - arrow
gnlow committed Sep 23, 2023
commit 48e4ce5641af5779813a972f2b25835744c7350a
6 changes: 5 additions & 1 deletion src/func/basic.ts
Original file line number Diff line number Diff line change
@@ -10,4 +10,8 @@ export const ref =

export const def =
(name: Expr, expr: Expr): Expr =>
({def: [name, expr]})
({def: [name, expr]})

export const arrow =
(from: Expr, to: Expr): Expr =>
({arrow: [from, to]})
25 changes: 13 additions & 12 deletions test/arrow.test.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import {
any,

and,
arrow,
ref,
def,
literal,
@@ -18,20 +19,20 @@ import { f } from "../src/util/mod.ts"
Deno.test("Arrow - Match Literal", () => {
assertEquals(
call(
{arrow: [
arrow(
literal("hello"),
literal("bye"),
]},
),
literal("hello"),
),
literal("bye"),
)
assertNotEquals(
call(
{arrow: [
arrow(
literal("hello"),
literal("bye"),
]},
),
literal("hell"),
),
literal("bye"),
@@ -42,14 +43,14 @@ Deno.test("Arrow - Multiple Match", () => {
assertEquals(
call(
and(
{arrow: [
arrow(
literal("1"),
literal("2"),
]},
{arrow: [
),
arrow(
literal("2"),
literal("4"),
]},
),
),
literal("2"),
),
@@ -60,10 +61,10 @@ Deno.test("Arrow - Multiple Match", () => {
Deno.test("Arrow - Capture", () => {
assertEquals(
call(
{arrow: [
arrow(
{capture: ["n", any]},
f({mul: [ref("n"), literal(2)]}),
]},
),
literal(123),
),
literal(246),
@@ -73,10 +74,10 @@ Deno.test("Arrow - Capture", () => {
Deno.test("Arrow - Junction", () => {
assertEquals(
call(
{arrow: [
arrow(
{capture: ["n", any]},
f({mul: [ref("n"), literal(2)]}),
]},
),
or(literal(10), literal(20)),
),
or(literal(20), literal(40)),