Version Packages#2
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
fcc82fc to
a3ac202
Compare
a3ac202 to
9ab39d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
pascal-code-formatter@0.1.0
Minor Changes
00944ab: Add
formatPascalSource(code, options?): an AST-driven formatter that parses thesource and pretty-prints the parser's AST into clean, consistently indented Pascal
text (a string). Because structure comes from the AST rather than string-matching the
token stream, classification is exact and parentheses are precedence-aware (
a + b * c,not
(a + (b * c))). Verified to round-trip (output re-parses), be idempotent, andpreserve semantics (the formatted source compiles to identical JS) across the golden
fixtures. Also exports
AstFormatterand theAstFormatOptionstype.The existing token-stream
formatPascalCodeis unchanged. This adds a dependency onpascal-parser.Patch Changes
3035567: Drop the
objects-deep-comparedependency and simplify the indentation tracker. Thebegin/end/var nesting is now an explicit local marker stack instead of a general-purpose
counterweight structure plus per-token deep-equality — clearer, testable without an
external dependency, and one fewer package to install. Output is unchanged.
f5e4ec8: Fix
formatPascalCodeproducing output that its own parser would reject.needWhiteSpacehad an ad-hoc allow-list with no rule to separate two adjacent word tokens, so control
keywords glued to their neighbours (
for+i,to+5,do+writeln,then+the body).Spacing is now driven by a general rule — a space between any two word-like tokens
(keyword/identifier/number/boolean/string, which also covers the
div/mod/and/or/notword operators) plus a leading space before control keywords after
)/]. Trailingwhitespace is no longer emitted on a token that ends its line. Added a round-trip test
harness that renders the formatted lines and re-parses them, covering for/while/if-then/case
bodies on the same line as their header.
1965329: Track source positions through the toolchain.
line(1-based),column(1-based) and
offset(0-based) marking where it starts in the source. Positionsare computed with a forward-only cursor, so tokenizing stays O(n).
ParseErrornow reports where the input went wrong — itsmessage is suffixed with
at line L, column Cand itslocationpoints at theoffending token, instead of a bare, position-less message.
compares tokens by structural identity, not deep object equality).
Updated dependencies [14fe8d3]
Updated dependencies [a3f86d6]
Updated dependencies [d8861ac]
Updated dependencies [1965329]
pascal-js-compiler@0.4.0
Minor Changes
CompileError. Unsupported-Pascal errors —var(by-reference)parameters, bitwise
and/or/notover integers, and wrong-arity builtin calls —now throw
CompileErrorinstead of a bareError, so a consumer cancatchand tell"this program uses an unsupported feature" apart from an internal compiler bug (which
stays a plain
Error). MirrorsParseErrorinpascal-parser.Patch Changes
low-bounds were tracked in a single flat map keyed only by name, so a local
array[1..n]inside a subprogram overwrote the low-bound of a same-named outer array, making the outer
array's 1-based index offset wrong (writes/reads landed outside the allocated array). Array
scope is now snapshotted and restored around each subprogram body, so a homonym array in one
scope no longer changes the meaning of the same identifier in a sibling or outer scope.
CompileErrorinstead of emitting acall to a nonexistent JS function. A value-returning builtin used as a statement
(
abs(x);) and a statement-only builtin used in an expression (x := writeln(1)) used tocompile to
abs(x);/writeln(1), which throwReferenceErrorat runtime. They now failat compile time, consistent with how the compiler already rejects
varparameters andwrong arity. A user subprogram sharing a builtin's name still shadows it in either position.
"type": "commonjs"explicitly in package.json. The packages already shipCommonJS; stating it removes Node's module-type detection step for consumers (as flagged
by publint) and brings these three in line with
pascal-code-formatter.pascal-parser@0.3.0
Minor Changes
14fe8d3:
Declarationis now a discriminated union (VariableDeclaration | FunctionDeclaration | ProcedureDeclaration | ConstantDeclaration) instead of one wide interface where everyfield was optional. Each variant is exported and carries exactly the fields it has, so a
switch (decl.type)narrows to the concrete node with no cast — matching howStatementand
Expressionalready work. Consumers that switch ondecl.typegain precise fieldtypes; code that read fields like
decl.parametersoff a bareDeclarationwithoutnarrowing must now narrow first.
d8861ac: Statement AST nodes now carry their real source location (
location.start= theline/column/offset of their first token), stamped in
parseStatement. Previouslyevery node location was zeroed. This enables consumers to map a statement back to
its source line — the playground step-debugger being the first such consumer.
Expression and declaration nodes remain zeroed until they too have a position
consumer.
1965329: Track source positions through the toolchain.
line(1-based),column(1-based) and
offset(0-based) marking where it starts in the source. Positionsare computed with a forward-only cursor, so tokenizing stays O(n).
ParseErrornow reports where the input went wrong — itsmessage is suffixed with
at line L, column Cand itslocationpoints at theoffending token, instead of a bare, position-less message.
compares tokens by structural identity, not deep object equality).
Patch Changes
"type": "commonjs"explicitly in package.json. The packages already shipCommonJS; stating it removes Node's module-type detection step for consumers (as flagged
by publint) and brings these three in line with
pascal-code-formatter.pascal-tokenizer@0.1.0
Minor Changes
1965329: Track source positions through the toolchain.
line(1-based),column(1-based) and
offset(0-based) marking where it starts in the source. Positionsare computed with a forward-only cursor, so tokenizing stays O(n).
ParseErrornow reports where the input went wrong — itsmessage is suffixed with
at line L, column Cand itslocationpoints at theoffending token, instead of a bare, position-less message.
compares tokens by structural identity, not deep object equality).
Patch Changes
"type": "commonjs"explicitly in package.json. The packages already shipCommonJS; stating it removes Node's module-type detection step for consumers (as flagged
by publint) and brings these three in line with
pascal-code-formatter.