Warning: This is an interest project aimed at learning TypeScript and compiler principles. Some parts of the code in this project are generated using ChatGPT. If you want to obtain production availability, please use starlark-go or starlark-rust.
# Need TypeScript and node.js environment
$ git clone https://github.com/Hanaasagi/starlark-ts
$ npm install
$ make build
$ npm run start # Enter the REPL, or `npm run start [filepath]` to run script
The code provides an example of the syntax of Starlark:
# Define a number
number = 18
def fizz_buzz(n):
"""Print Fizz Buzz numbers from 1 to n."""
for i in range(1, n + 1):
s = ""
if i % 3 == 0:
s += "Fizz"
if i % 5 == 0:
s += "Buzz"
print(s if s else i)
fizz_buzz(number)
- Implement the language specification
- Builtin Types
- bool
- int (JavaScript BigInt)
- float (JavaScript Number)
- string
- bytes
- list
- tuple
- dict
- set
- Control flow
- if/else
- for/range
- while
- break/continue
- operator
-
+
-
-
-
*
-
/
-
//
-
%
-
>
,>=
,==
... comparison operator -
and
-
or
-
in
-
not in
-
|
-
^
-
&
-
- Function
- Positional arguments
- Keyword arguments
- Variable length arguments
- return
- Module
- load
- Builtin Types
Reference Starlark Spec
Starlark-ts is Apache License, version 2.0 licensed, as found in the LICENSE file.