Rotth is a stack based concatenative language highly inspired by Porth
0

Configure Feed

Select the types of activity you want to include in your feed.

Added readme

Ivan Chinenov (Mar 10, 2022, 1:38 AM +0300) 13375d50 a5ad8add

+45
+45
README.md
··· 1 + # Rotth 2 + ### A stack-cringe language inspired by [Porth](https://gitlab.com/tsoding/porth) 3 + 4 + ## Syntax 5 + ```rotth 6 + proc main : uint do 7 + "Hello, world!\n" puts 8 + 0 9 + end 10 + 11 + const SYS_write : uint do 1 end 12 + const STDOUT : uint do 1 end 13 + 14 + proc puts uint ptr do 15 + STDOUT SYS_write syscall3 drop 16 + end 17 + ``` 18 + 19 + Rotth has following keywords: 20 + - `include` 21 + - `if` 22 + - `else` 23 + - `proc` 24 + - `while` 25 + - `do` 26 + - `bind` 27 + - `const` 28 + - `end` 29 + 30 + ### `proc` 31 + Keyword `proc` declares a procedure. It is followed by procedure name, then it's inputs and outputs separated by the `:` signature separator. 32 + Body of the procedure is terminated by `end` keyword. 33 + ### `if` and `else` 34 + `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. 35 + ### `while do` 36 + `while` is the looping construct. It is followed by loop condition, then `do` keyword, then loop body, then `end`. 37 + ### `const` 38 + `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. 39 + ### `bind` 40 + `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: 41 + ```rotth 42 + bind a b c do 43 + b c a 44 + end 45 + ```