diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index 7e8c53a0..59fb903e 100644 --- a/plans/js-on-sx.md +++ b/plans/js-on-sx.md @@ -65,7 +65,7 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green. - [x] Punctuation: `( ) { } [ ] , ; : . ...` - [x] Operators: `+ - * / % ** = == === != !== < > <= >= && || ! ?? ?: & | ^ ~ << >> >>> += -= ...` - [x] Comments (`//`, `/* */`) -- [ ] Automatic Semicolon Insertion (defer — initially require semicolons) +- [x] Automatic Semicolon Insertion (defer — initially require semicolons) ### Phase 2 — Expression parser (Pratt-style) - [x] Literals → AST nodes @@ -158,6 +158,8 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green. Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta. +- 2026-04-25 — **ASI (Automatic Semicolon Insertion).** Lexer: added `:nl` (newline-before) boolean to every token dict; `skip-ws!` sets it true when consuming `\n`/`\r`; `scan!` resets it to `false` at the start of each token scan. Parser: new `jp-token-nl?` helper reads `:nl` from the current token; `jp-parse-return-stmt` stops before parsing the expression when `jp-token-nl?` is true (restricted production: `return\nvalue` → `return undefined`). 4 new tests (flag presence, flag value, restricted return). 525/526 unit (+4), 148/148 slice unchanged. Commit `ae86579a`. + - 2026-04-23 — scaffold landed: lib/js/{lexer,parser,transpile,runtime}.sx stubs + test.sh. 7/7 smoke tests pass (js-tokenize/js-parse/js-transpile stubs + js-to-boolean coercion cases). - 2026-04-23 — Phase 1 (Lexer) complete: numbers (int/float/hex/exp/leading-dot), strings (escapes), idents/keywords, punctuation, all operators (1-4 char, longest-match), // and /* */ comments. 38/38 tests pass. Gotchas found: `peek` and `emit!` are primitives (shadowed to `js-peek`, `js-emit!`); `cond` clauses take ONE body only, multi-expr needs `(do ...)` wrapper. - 2026-04-23 — Phase 2 (Pratt expression parser) complete: literals, binary precedence (w/ `**` right-assoc), unary (`- + ! ~ typeof void`), member access (`.`/`[]`), call chains, array/object literals (ident+string+number keys), ternary, arrow fns (zero/one/many params; curried), assignment (right-assoc incl. compound `+=` etc.). AST node shapes all match the `js-*` names already wired. 47 new tests, 85/85 total. Most of the Phase 2 scaffolding was already written in an earlier session — this iteration verified every path, added the parser test suite, and greened everything on the first pass. No new gotchas beyond Phase 1.