From 37b9da32d3b911091deb254f6cba2a137c471287 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 12 Oct 2023 10:51:58 +0200 Subject: move to a direct byte code compiler (#8) * chore: refactor to keep only the new parser and bytecode vm * scanner: remove Token.value field * scanner: remove scanner.kind field * chore: move language specification in lang package This avoid a cyclic dependency in scanner_test which can now use the golang/GoSpec language specification for Go. * clean code * scanner: export scanner fields Also parser now generate function calls, including externals. * chore: fix lint issues * parser: handle strings * wip * parser: implement support for 'if, else, else if' statements Resolving labels in the compiler still in progress. * parser: support if statements, improve compiler * improve handling of functions * improve support of local variables * scanner: trim leading and trailing spaces * fixes to make fibonacci work * parser: improve README, fix function parameters parsing --- _samples/p05 | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 _samples/p05 (limited to '_samples/p05') diff --git a/_samples/p05 b/_samples/p05 new file mode 100644 index 0000000..51c2c9b --- /dev/null +++ b/_samples/p05 @@ -0,0 +1,10 @@ +func f(i int) int { + if i < 2 { + if i == 1 { + return + } } + println("i", i) +} + +f(1) +println("bye") -- cgit v1.2.3