Walkson
Walkson is a stack based 1 dimensional programming language meant as a easy as possible to implement scripting language with a unique architecture to completely forego needing a parser.
Concepts
Walkson is meant to be a fully usable and readable c-like language that abuses stacks where they shouldnt be to be implementable without needing a pesky parser to handle Context. To achieve this the language has 3 Stacks:
- The Primary Stack
- The Name Stack
- The Type Stack
Every non keyword token is put onto one of these stacks and pop them based on the keyword.
Instructions
The instruction type looks like this:
struct Instruction {
origin_file: &Path,
line: usize,
pos: usize,
instruction_type: InstructionType
}
where InstructionType is a tagged union (or in rusts case enum) which contains token etc.
Full List of Instructions
PushString String
- Pushes a string literal to the primary stack
PushInt Integer
- Pushes an integer literal to the primary stack
PushFloat Float
- Pushes a floating point number to the primary stack
PushName String
- Pushes a string to the name stack
PushType String
- Pushes a refrence to a type to the type stack
Execution
Instruction can be executed one by one in a for loop, since it currently uses only recursion for loops, meaning the state is only the three stacks, the variables, the types, the functions, the function mode bool, and the if mode bool (could potentially both be replaced by an instruction buffer and an instruction pointer + navigation instructions).
Examples
Hello, World!
A simple Hello World Program:
"Hello World" print
Cat
Takes a filename from stdin, reads the file and prints it.
// gets stdin and calls String.split $stdin get String.split call // creates a buffer of strings as a variable stdin let // indexes into the first element, to put it onto the stack stdin 0 index // reads and prints it read print
Truth Machine
Takes a number from stdin and if its 0 it prints 0 and exits else it'll print one indefinitely.
$stdin get String.split call stdin let stdin 1 index String.parse_int call pop
...