Jason
Automatic DSL Generator, using the new CFG API
Core trick
Asks OpenAI for a strict-subset Lark grammar, compiles it to a JavaScript parser via lark-js, and derives the AST schema from it.
Tags
Description
Automatic DSL Generator, using the new CFG API
README excerpt
# Disclaimer This was made in a total of about 6 hours during the Shack15 GPT-5 hackathon. Maybe it will serve as useful to folks on a draft version of an interpreter or as inspiration for other projects. ---- # lang-gen End-to-end DSL generator with grammar-constrained output from OpenAI. ## Features - Generates strict-subset Lark grammars from natural language descriptions - Compiles grammars to JavaScript parsers using lark-js - Auto-derives AST schema from grammar structure - Generates interpreters based on semantic descriptions - **VSCode extension generation** with syntax highlighting - No hardcoded language semantics - everything is generated at runtime ## Installation ```bash # Install dependencies (this will also set up Python environment) npm install # The postinstall script automatically: # 1. Creates a Python virtual environment # 2. Installs lark-js in the venv # 3. Verifies the installation # If you need to manually run setup: ./setup.sh ``` ### Requirements - Node.js 18+ - Python 3 (for lark-js compiler) - OpenAI API key ## Usage ```bash # Basic usage node index.js --spec "tiny calc with ints + - * / and parens" --semantics "evaluate to a number" # With sample code to test node index.js --spec "boolean logic with AND OR NOT" --semantics "evaluate to true/false" --sample "true AND (false OR true)" # Read semantics from stdin echo "compile to JavaScript code" | node index.js --spec "simple expression language" # Specify output directory node ind