diff --git a/StackBasedLanguage/errors.md b/StackBasedLanguage/errors.md new file mode 100644 index 0000000..4d4be5d --- /dev/null +++ b/StackBasedLanguage/errors.md @@ -0,0 +1,38 @@ +# All GRSBPL Error Messages + +## Syntax Errors + +- Any uncaught exception occurs during lexing: + `Unknown Syntax Error. : ` + +- Invalid character escaped: + `Invalid escape sequence ` + +- Integer parse failed (can only happen because number is too big) + `Value not an integer: ` + +## Runtime Errors + +- Label not found + `Label '' not found` + +- Function not found + `Function '' not found` + +- Stack empty on return + `Function has to return some value, but no value was found on the stack` + +- Pop called on empty stack + `Cannot pop empty stack` + +- No stack frame left after return + `Tried to return outside of function, probably forgot to skip a function` + +- Stackoverflow - limit 1 000 000 + `Stackoverflow. Limit of stack frames reached.` + +- Invalid token found + `Excepted token '' but found ''` + +- Failed to read input from stdin + `[VM] - Error reading input` \ No newline at end of file diff --git a/StackBasedLanguage/fizzbuzz.grsbpl b/StackBasedLanguage/fizzbuzz.grsbpl new file mode 100644 index 0000000..2253b4f --- /dev/null +++ b/StackBasedLanguage/fizzbuzz.grsbpl @@ -0,0 +1,9 @@ +10 factorial 1 goto exit + +function factorial 1 +dup not goto isZero +pop dup 1 - factorial * return +:isZero +1 pop return + +:exit pop dup nout \ No newline at end of file diff --git a/StackBasedLanguage/pom.xml b/StackBasedLanguage/pom.xml index 5fb4e18..c3e018f 100644 --- a/StackBasedLanguage/pom.xml +++ b/StackBasedLanguage/pom.xml @@ -25,6 +25,7 @@ 14 14 + UTF-8 \ No newline at end of file