Tiny Stack Language
Tiny Stack Language or TSL is a small, esoteric, Turing-complete language that lets you interact with a stack in memory.
More documentation on the grammar is in grammar.md.
while (vssize < 10) {
push vssize;
}
peek;
for (vssize-1) {
pop;
peek;
}
produces, as output,
9 8 7 6 5 4 3 2 1 0
TSL Grammar Definition
program -> statement* EOF
statement -> stack_statement ";"
| if_statement
| for_statement
| while_statement
| expression ";"
stack_statement -> "push" expression ";"
| "pop" ";"
| "peek" ";"
| "sanitize" ";"
if_statement -> "if" "(" expression ")" block
for_statement -> "for" "(" expression ")" block
while_statement -> "while" "(" expression ")" block
block -> "{" statement* "}"
expression -> implication
implication -> logic_or (("imply" | "nimply") logic_or)*
logic_or -> logic_and ("or" logic_and)*
logic_and -> equality ("and" equality)*
equality -> relational (("==" | "<>" ) relational)*
relational -> add (("<" | ">" | "<=" | ">=") add)*
add -> mul (("+" | "-") mul)*
mul -> unary (("*" | "/") unary)*
unary -> ("not" | "-") unary
| primary
primary -> NUMBER
| "(" expression ")"
Literals available for use in expressions --
vpeek -> value if peek is evaluated then vssize -> current size of stack vempty -> boolean, is the stack empty
Get the code >