···11+# Rotth
22+### A stack-cringe language inspired by [Porth](https://gitlab.com/tsoding/porth)
33+44+## Syntax
55+```rotth
66+proc main : uint do
77+ "Hello, world!\n" puts
88+ 0
99+end
1010+1111+const SYS_write : uint do 1 end
1212+const STDOUT : uint do 1 end
1313+1414+proc puts uint ptr do
1515+ STDOUT SYS_write syscall3 drop
1616+end
1717+```
1818+1919+Rotth has following keywords:
2020+- `include`
2121+- `if`
2222+- `else`
2323+- `proc`
2424+- `while`
2525+- `do`
2626+- `bind`
2727+- `const`
2828+- `end`
2929+3030+### `proc`
3131+Keyword `proc` declares a procedure. It is followed by procedure name, then it's inputs and outputs separated by the `:` signature separator.
3232+Body of the procedure is terminated by `end` keyword.
3333+### `if` and `else`
3434+`if` keyword is a primary conditional construct of the language. It must be preceded by an expression of type `bool` and followed by true branch, then by optional `else` branch and finally by `end` terminator.
3535+### `while do`
3636+`while` is the looping construct. It is followed by loop condition, then `do` keyword, then loop body, then `end`.
3737+### `const`
3838+`const` followed by name and type, separated by `:`, declares a compile-time constant. It supports limited compile-time evaluation, syscalls and user-defined proc calls are not allowed.
3939+### `bind`
4040+`bind` is similliar to destructuring in traditional functional languages, it iakes elements from the stack and allows using them as local constants. For example this is how you can implement `Forth` `rot` word using it:
4141+```rotth
4242+bind a b c do
4343+ b c a
4444+end
4545+```