diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -8,9 +8,9 @@ It aims to be clean and succinct while performant: inspired by the syntax and me ```nim import std/tables -mod Ast: +mod ast: pub type Value = interface - func repr(self: Self): string + repr(Self): string pub type Ident = string pub type Expr = ref union Literal: ref Value @@ -20,19 +20,19 @@ mod Ast: Conditional: struct cond, then_branch, else_branch: Expr - pub func eval(expr: Expr, context: var HashTable[Ident, Value]): Result[Value] + pub func eval(expr: Expr, context: var HashTable[Ident, Value]): Result[Value, ref Err] match expr of Literal(value): Okay(value) of Variable(ident): context.get(ident) - of Application{body, arg}: - if body of Abstraction{param, body as inner_body}: + of Application(body, arg): + if body of Abstraction(param, body as inner_body): context.set(param, eval(arg)) inner_body.eval(context) else: Error(InvalidExpr) - of Conditional{cond, then_branch, else_branch}: + of Conditional(cond, then_branch, else_branch): if eval(cond, context): then_case.eval(context) else: @@ -40,7 +40,7 @@ mod Ast: of _: Error(InvalidExpr) -Ast.eval("(λx.x) 413".parse(), HashTable.init()) +ast.eval("(λx.x) 413".parse(), HashTable.init()) ``` ## Why Puck? |