Repository navigation
v0.8.0
Minor Changes
-
#145
8f2c8c6Thanks @JounQin! - Return the full shell syntax tree and keep printing source text.Breaking changes
-
Node.js >=18 is required.
-
The AST is no longer Go-shaped. Fields are lowerCamelCase and node
positions are explicit: usenode.type,start/end, and
{ offset, line, column }objects instead ofPos/End,Stmts,
Cmd,Parts,Value, and the other Go field names. -
ParseError/IParseErrorfields are renamed from Go style:
Filename→filename,Incomplete→incomplete,Text→text,
andPos→pos. -
Operator-valued fields (
op) now use the upstream numeric enum values instead
of display strings. Typed constants such asRedirOperator,
CaseOperator,ProcOperator, andBinAritOperatorare exported. -
Word.Litis gone; useparts.File.Lastis nowlastComments. -
print(ast)withoutoriginalTextis no longer supported and throws a
TypeError. Printing an edited AST is deferred to a follow-up; the AST is
currently a parse result, not a second input format.
Features
parse()now returns every node and field frommvdan.cc/sh's syntax
package instead of only positions. The tree is plain JSON-compatible data:
every node hastype,start, andend; fields use lowerCamelCase; and
position fields are{ offset, line, column }objects.- Add a
walk()helper for the typed tree; usenode.typeinstead of a
node-type helper. - Public AST types are a discriminated union:
BaseNodeplus literal
typefields, withNode,Command,WordPart,Loop,
ArithmExpr, andTestExprunions sonode.typenarrows in TypeScript. print()continues to format source text.print(ast, { originalText })
andprocessor(ast, { originalText })remain accepted for tooling
compatibility, but the AST is deliberately ignored andoriginalTextis
formatted.getProcessor()caches the compiled WebAssembly module, uses
compileStreaming()forapplication/wasmresponses, accepts
Buffer/BufferSource/Response/response-like sources, and instantiates a
fresh runtime per call.- Add
parseSync()andprintSync()for bounded synchronous work, plus
getProcessorSync()for preloaded WASM bytes or a synchronous loader.
Long-lived processes should use the async APIs; the TinyGo leaking GC means
unbounded synchronous loops accumulate memory. - Positions recovered by
recoverErrorsnow exposerecovered: true.
-