Skip to content

Latest commit

 

History

History
80 lines (67 loc) · 1.87 KB

README.md

File metadata and controls

80 lines (67 loc) · 1.87 KB

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 or 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:

# 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)

TODOs

  • 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

Reference Starlark Spec

License

Starlark-ts is Apache License, version 2.0 licensed, as found in the LICENSE file.