An interpreted language with a JavaScript-like syntax, written in Typescript. It features a lexer, ast, parser, interpreter, REPL and file runner.
- Syntax and Features
- Installation
- Available Scripts
- Usage
- Roadmap
- Contributing
- License
- Acknowledgements
- Number
3,3.14 - String
"Hello, World!" - Boolean
true,false - Null
null - Array
[1, 2, 3] - Object
{ key: "value" }
- Logical
! - Negation
- - Positive
+
- Multiplicative
(*, /, //, %) - Additive
(+, -) - Relational
(==, !=, <, <=, >, >=) - Logical
(&&, ||)
x = 3foo[0]
foo[3 + 4]
foo["bar"]foo.barconst foo = []
foo.length
foo.push(3)add(3, 4)const PI = 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("foo")
}for let i = 0; i < 10; i = i + 1 {
print(i)
}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 commentprint("Hello, World!")
const name = input("What is your name?")
random()
random(1, 10)
typeof(3)Ensure you have Bun (v1.1.x or higher) installed.
bun install| Command | Description |
|---|---|
bun lint |
Lint |
bun test |
Test |
bun run repl |
Run the REPL |
bun file <file> |
Run a file |
Example file program.st:
fn add(a, b) {
let sum = a + b
return sum
}
let result = add(3, 4)
const foo = {
result: result / 3,
add,
isBar: 1 > 2 || 3 < 4,
}
if foo["is" + "Bar"] {
print("foo is bar")
} else {
print("foo is not bar")
}
print(foo.result)
print(foo.add(3, 4))
for let i = 0; i < 10; i = i + 1 {
print(i)
}
fn counter() {
let count = 0
fn increment() {
count = count + 1
return count
}
return increment
}
const increment = counter()
while increment() < 10 {
print(increment())
}Run file: bun file program.st
- Control Flow (elif)
- Update expressions (++, --) postfix/prefix and (+=, -=, ...)
- Error handling (try-catch, throw)
- Better error messages with line numbers, context, etc.
- OOP
- Types
- Standard library
- Modules
- Improve REPL, add history, autocomplete, etc.
- Syntax highlighting (VSCode extension)
- Rewrite in Rust
- Fork the project
- Create your feature branch (
git checkout -b fix/tokenizer-number-parsing) - Commit your changes (
git commit -m 'fix: parsing numbers') - Push to the branch (
git push origin fix/tokenizer) - Open a PR
Distributed under the MIT License. See LICENSE for more information.