Expand description
Minimal JavaScript AST and pretty-printer for Husk codegen.
This crate currently defines:
- A small JS AST (expressions, statements, modules).
- A pretty-printer that renders the AST to a JS source string.
- A minimal lowering from Husk AST to this JS AST for simple functions.
- Source map generation for debugging.
Structs§
- JsModule
- A JavaScript module (ES module) consisting of a list of statements.
- Source
Span - Source span for mapping back to Husk source.
Enums§
- Destructure
Pattern - Pattern element for array destructuring (supports nesting).
- JsAssign
Op - Assignment operators in JS.
- JsBinary
Op - Binary operators in JS (subset we need).
- JsExpr
- JavaScript expressions (subset).
- JsStmt
- JavaScript statements (subset).
- JsTarget
- Output target style.
- JsUnary
Op - Unary operators in JS.
Functions§
- file_
to_ dts - Convert a Husk AST file into a
.d.tsTypeScript declaration string. - lower_
file_ to_ js - Lower a Husk AST file into a JS module.
- lower_
file_ to_ js_ with_ source - Lower a Husk AST file into a JS module with source text for accurate source maps.
- offset_
to_ line_ col - Compute line and column (0-indexed) from a byte offset in source text.