Skip to main content

A Python port of the LynxScript compiler

Project description

🐱 LynxScript (Python Port)

LynxScript is a programming language designed for CatWeb, a Roblox game where users can build website-esque creations. The LynxScript compiler compiles source code files into a JSON format that can be imported directly into CatWeb.

This project is a complete, architecturally faithful port of the original Rust implementation into Python 3.10+.

Usage

Syntax

LynxScript features a syntax familiar to web developers:

// Familiar syntax to web-devs
console.log("Hello, world!");

// In-language standard library definition
#[export_as("console.log")]
function log(arg) {
  // Raw CatWeb block ID calls
  #0(#"", arg);
}

Command Line Interface

You can compile a LynxScript source file to JSON using the following CLI arguments:

# Compile a LynxScript source file to JSON and output it to output.json
lync --compile ./src/main.lxs --output ./out/output.json

# Or just output the JSON onto the console
lync -c ./src/main.lxs
# (-c is shorthand for --compile, and -o for --output)

If you are running directly from the source directory, you can invoke the module via Python:

python -m lynxscript.main -c <path_to_script>.lxs -o <output_path>.json

Features & Roadmap

  • Function declarations
  • Event handlers
  • Raw CatWeb block ID calls
  • In-language standard library implementation
  • Link statement (Importing site JSON files and referencing UI objects)
  • Arbitrary expression compilation (binary, boolean)
  • Return statements
  • If statements
  • Loops
  • Optimizations
    • Function inlining
    • Constant folding
    • Dead code elimination

Installation

You can install lynxscript directly from PyPI:

pip install lynxscript

Or install it locally in editable mode for development:

  1. Clone the repository.
  2. Go to the project directory and run:
    pip install -e .
    
  3. You can now use the lync command directly in your terminal!

Development & Testing

Prerequisites

  • Python 3.10 or newer.
  • pytest for running tests (installed automatically via requirements.txt or as dev dependency).

Running Tests

To run tests (which verify the parser and compiler AST output matches character-for-character with original Rust snapshots):

pytest

License

This project is licensed under the MIT License.

Acknowledgments

  • Similar project: catlua also shaped the ecosystem of CatWeb text-based programming languages ✨
  • Original Rust implementation by pickaxe828.

Rewritten in Python by Ziad.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lynxscript-0.1.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lynxscript-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file lynxscript-0.1.1.tar.gz.

File metadata

  • Download URL: lynxscript-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lynxscript-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d84b3cb2448f8345bcebfe204afb8a163cbb5b3c535599fb086e2326fce368d1
MD5 af748156d5aa837ccc9ded8328f86f47
BLAKE2b-256 7da59a799f953aff866ce556fe71f04686415179ffe3ecae4efffbc700d5239c

See more details on using hashes here.

File details

Details for the file lynxscript-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lynxscript-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lynxscript-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b40647fad60ee26d005d8f3a5189ffc0926e688240f1cbf1d81620127d3543d
MD5 febd9822640ab9128853b8ef51a003a5
BLAKE2b-256 5e2d941c90e3daaa76e2287e0687fff7bfdef47d06a3f6f757f83f470b210ee2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page