An interpreted language with a javascript-like syntax and some overlapping features from Python, written in Typescript. Features a lexer, ast, parser, and interpreter, with a repl and file runner.
- Number
3
,3.14
- String
"Hello, World!"
- Boolean
true
,false
- Null
null
- Array
[1, 2, 3]
- Object
{ key: "value" }
- Logical
!
- Negation
-
- Multiplicative
(\*, /, //, %)
- Additive
(+, -)
- Relational
(==, !=, <, <=, >, >=)
- Logical
(&&, ||)
x = 3
foo[0]
foo[3 + 4]
foo["bar"]
foo.bar
const foo = []
foo.length
foo.push(3)
add(3, 4)
const foo = 3
let bar = "Hello, World!"
limited to if-else for now, parentheses are optional
if 3 > 2 {
print("3 is greater than 2")
} else {
print("3 is equal to 2")
}
let i = 0
while i < 10 {
print(i)
i = i + 1
}
Function declarations support both closures and recursion.
fn fib(n) {
if n <= 1 {
return n
}
return fib(n - 1) + fib(n - 2)
}
# this is a comment
print("Hello, World!")
const name = input("What is your name?")
random()
random(1, 10)
typeof(3)
bun install
Command | Description | Example |
---|---|---|
bun run repl |
Run the repl | |
bun file <file> |
Run a file | bun file program.st |
Example file program.st
:
fn add(a, b) {
let sum = a + b
return sum
}
const result = add(3, 4)
const foo = {
result: result / 3,
add,
isBar: 1 > 2 || 3 < 4,
}
let key = "isBar"
if foo[key] == "isBar" {
print("foo is bar")
} else {
print("foo is not bar")
}
print(foo.result)
print(foo.add(3, 4))
fn counter() {
let count = 0
fn increment() {
count = count + 1
return count
}
return increment
}
let increment = counter()
while increment() < 10 {
print(increment())
}
Run file: bun file program.st
- Fix binary operators and unary for different types
- Control Flow (elif)
- Update expression (++, --) postfix/prefix
- Better Error Messages with Line Numbers and Context
- Error Handling (try-catch, throw)
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.