Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanaasagi/starlark-ts
:ringed_planet: Starlark language implemented in pure TypeScript.
https://github.com/hanaasagi/starlark-ts
compiler interpreter starlark
Last synced: about 1 month ago
JSON representation
:ringed_planet: Starlark language implemented in pure TypeScript.
- Host: GitHub
- URL: https://github.com/hanaasagi/starlark-ts
- Owner: Hanaasagi
- License: apache-2.0
- Created: 2023-02-26T04:33:43.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-28T16:04:38.000Z (almost 2 years ago)
- Last Synced: 2024-12-08T22:40:02.379Z (about 1 month ago)
- Topics: compiler, interpreter, starlark
- Language: TypeScript
- Homepage:
- Size: 713 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# starlark-ts
**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](https://github.com/google/starlark-go) or [starlark-rust](https://github.com/facebookexperimental/starlark-rust).
### Build and Install
```
# 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:
```python
# Define a number
number = 18def 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)
```### TODOs
- [ ] Implement the language specification
- [ ] Builtin Types
- [x] bool
- [x] int (JavaScript BigInt)
- [x] float (JavaScript Number)
- [x] string
- [ ] bytes
- [x] list
- [x] tuple
- [x] dict
- [x] set
- [x] Control flow
- [x] if/else
- [x] for/range
- [x] while
- [x] break/continue
- [x] operator
- [x] `+`
- [x] `-`
- [x] `*`
- [x] `/`
- [x] `//`
- [x] `%`
- [x] `>`, `>=`, `==` ... comparison operator
- [x] `and`
- [x] `or`
- [x] `in`
- [x] `not in`
- [ ] `|`
- [ ] `^`
- [ ] `&`
- [ ] Function
- [x] Positional arguments
- [x] Keyword arguments
- [ ] Variable length arguments
- [x] return
- [ ] Module
- [ ] loadReference [Starlark Spec](https://github.com/bazelbuild/starlark/blob/master/spec.md)
### License
Starlark-ts is Apache License, version 2.0 licensed, as found in the LICENSE file.