typestack-lang
v1.6.8
Published
A stack-based, type-safe programing language
Downloads
7
Readme
TypeStack
A stack-based, type-safe language
Warning This is a work in progress language
Instillation for CLI
npm install typestack-lang -g
Running Files via CLI
# tsk is the file extension for typestack
typestack filename.tsk
VSCode
Download the extension to provide language support to .tsk
files.
Instillation for JavaScript
npm install typestack-lang
Running TypeStack
import typestack from "typestack-lang/dist/index.js";
await typestack(`
100 for loop {
dup 15 % 0 ==
if {
"FizzBuzz" print drop
} else {
int dup 5 % 0 ==
if {
"Buzz" print drop
} else {
int dup 3 % 0 ==
if {
"Fizz" print drop
} else {
int print
}
}
}
}
`);
Example FizzBuzz Program
100 for loop {
dup 15 % 0 ==
if {
"FizzBuzz" print drop
} else {
int dup 5 % 0 ==
if {
"Buzz" print drop
} else {
int dup 3 % 0 ==
if {
"Fizz" print drop
} else {
int print
}
}
}
}
Example Number Guess Program
# make the random number
1 100 rand
# repeat while the guess is wrong
loop {
"Guess a number: " int read
over over # create a copy of the guess and random number
== if {
"You are correct!" print
break
} else {
int over # create a copy of the random number on the top
> if {
"Too high!" print drop
} else {
"Too low!" print drop
}
}
}