From c067a1f0ec3f8e089d2800e18da7f3db4f3c2a33 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Thu, 6 Apr 2017 11:12:11 +0100 Subject: Fix ir bugs: global variable names, untyped to any assignment --- code/demo.odin | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'code') diff --git a/code/demo.odin b/code/demo.odin index af7f453c5..1aa76f03e 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -14,9 +14,18 @@ #import "utf16.odin"; main :: proc() { - if x := 0; x < 0 { - fmt.println(x); - } else { - fmt.println(x); + immutable program := "+ + * - /"; + accumulator := 0; + + for token in program { + match token { + case '+': accumulator += 1; + case '-': accumulator -= 1; + case '*': accumulator *= 2; + case '/': accumulator /= 2; + default: // Ignore everything else + } } + + fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator); } -- cgit v1.2.3