From bb783f8f31797597ca0349434e236e6df923e14b Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 7 Nov 2023 21:49:01 +0100 Subject: parser: implement switch statement A VM instruction `EqualSet` has been added to preserve the left operand on the stack in case of failure, to allow efficient multiple tests on the same value. Both the pattern 'if/else if' and the classical case clauses have been implemented. --- lang/token.go | 1 + 1 file changed, 1 insertion(+) (limited to 'lang') diff --git a/lang/token.go b/lang/token.go index 880f474..95a1be5 100644 --- a/lang/token.go +++ b/lang/token.go @@ -109,6 +109,7 @@ const ( JumpFalse JumpSetFalse JumpSetTrue + EqualSet ) func (t TokenId) IsKeyword() bool { return t >= Break && t <= Var } -- cgit v1.2.3