diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-04-06 11:12:11 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-04-06 11:12:11 +0100 |
| commit | c067a1f0ec3f8e089d2800e18da7f3db4f3c2a33 (patch) | |
| tree | 3b10cf9db6b738ef63199120eda0ca3e9bfada3b /code | |
| parent | 3e80411d374d3dd7fc90e22d4f900144cfb6ef3a (diff) | |
Fix ir bugs: global variable names, untyped to any assignment
Diffstat (limited to 'code')
| -rw-r--r-- | code/demo.odin | 17 |
1 files changed, 13 insertions, 4 deletions
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); } |