From cc1b3ad0c3e2375bff3d0d736b988d41840dcadd Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 10 May 2010 02:32:04 +0000 Subject: Add lambda expression syntax to Boot. * boot/parser.boot (bpLambda): New. * boot/ast.boot (bfLambda): New. * boot/tokens.boot: Add "+->" as token. * interp/cparse.boot: Use lambda expression syntax. * interp/c-util.boot: Likewise. --- src/boot/parser.boot | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/boot/parser.boot') diff --git a/src/boot/parser.boot b/src/boot/parser.boot index ce22eb37..e754375d 100644 --- a/src/boot/parser.boot +++ b/src/boot/parser.boot @@ -800,6 +800,9 @@ bpAssign()== bpEqPeek "BEC" => bpRestore a bpAssignment() or bpTrap() + bpEqPeek "GIVES" => + bpRestore a + bpLambda() or bpTrap() true bpRestore a false @@ -810,6 +813,14 @@ bpAssignment()== (bpAssign() or bpTrap()) and bpPush bfAssign (bpPop2(),bpPop1()) +++ Parse a lambda expression +++ Lambda ::= Variable +-> Assign +bpLambda() == + bpVariable() and + bpEqKey "GIVES" and + (bpAssign() or bpTrap()) and + bpPush bfLambda(bpPop2(),bpPop1()) + -- should only be allowed in sequences bpExit()== bpAssign() and (bpEqKey "EXIT" and -- cgit v1.2.3