Crate husk_codegen_js

Crate husk_codegen_js 

Source
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.
SourceSpan
Source span for mapping back to Husk source.

Enums§

DestructurePattern
Pattern element for array destructuring (supports nesting).
JsAssignOp
Assignment operators in JS.
JsBinaryOp
Binary operators in JS (subset we need).
JsExpr
JavaScript expressions (subset).
JsStmt
JavaScript statements (subset).
JsTarget
Output target style.
JsUnaryOp
Unary operators in JS.

Functions§

file_to_dts
Convert a Husk AST file into a .d.ts TypeScript 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.