diff options
author | Adrian Kummerlaender | 2017-04-15 13:40:17 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-15 13:41:02 +0200 |
commit | 5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9 (patch) | |
tree | 63b4e357a2e9db35f65f9b4d43ca9f8639ce0613 | |
parent | c6d2b259a4f253403929f6f1104395a6a71b1be6 (diff) | |
download | slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar.gz slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar.bz2 slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar.lz slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar.xz slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.tar.zst slang-5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9.zip |
Add README.md, example
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | source/primitives/conditional.d | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..83cb867 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# slang + +…a experimental Forth-like stack language implemented in D. + +## Example + + 1 i $ + § incr dup @ 1 + swp $ ; + § print @ . pop ; + § withinBounds @ 10 < ; + § loop i withinBounds if i print i incr loop then else ; + loop + +The above _slang_ code to be entered in the repl prints the numbers from 1 to 9. The repl may be compiled and executed using `dub run` in the project directory. diff --git a/source/primitives/conditional.d b/source/primitives/conditional.d index 678f516..08c0f52 100644 --- a/source/primitives/conditional.d +++ b/source/primitives/conditional.d @@ -26,7 +26,7 @@ bool drop(Token token) { case "if" : eval_if; break; case "then" : eval_then; break; case "else" : eval_else; break; - default : capture(token); break; + default : capture(token); break; } } else { capture(token); @@ -55,7 +55,7 @@ void eval_then() { void eval_else() { if ( concluded ) { - throw new Exception("`else` without preceding `if`"); + throw new Exception("`else` without preceding `if`"); } else { drop_mode = false; concluded = true; @@ -72,6 +72,6 @@ Stack!Token discharge() { buffer.nullify; return result; } else { - throw new Exception("unconcluded conditional may not be discharged"); + throw new Exception("unconcluded conditional may not be discharged"); } } |