Repository navigation
Read input data, prefixed mata: and python: openers, and #delimit ; star comments as Stata does - #414
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 38 minutes. View limit details
|
jbearak
force-pushed
the
t3/fix-lexer-input-context
branch
from
November 19, 2026 14:39
4578f8c to
dd85e02
Compare
…nts as Stata does Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
jbearak
force-pushed
the
t3/fix-lexer-input-context
branch
from
November 19, 2026 14:40
dd85e02 to
d4bae29
Compare
jbearak
added a commit
that referenced
this pull request
Nov 19, 2026
The blank-row check compared line numbers, which under #delimit ; is true for an empty block because the data starts on the input line. Caught by input-data-edge-cases.test.ts once main's #414 was merged in.
jbearak
added a commit
that referenced
this pull request
Nov 19, 2026
…ritten when formatting, and read abbreviated weights and foreach list types in parse --json (#419) * Keep embedded strings, option arguments, call parens and blank input rows as written, and read abbreviated weights and foreach list types in parse --json Formatter (both modes unless noted): - An inline python:/mata: statement whose string holds a ; before a comment marker ("a;\t//b") comes back byte for byte. Only a ; that ends the statement (a #delimit ; terminator, or a ; before ///) is kept outside the placeholder. - Under #delimit ;, a /// after the ; that ends a statement no longer makes the next statement a continuation line, so one format reaches the fixed point and the indentation diagnostic agrees. - AST mode prints option arguments as written instead of respacing them as expressions, which turned using(plugins/my.plugin) into using(plugins / my.plugin), format(%9.0g) into format(9.0g), eq(#2) into eq(2) and c:\data\x.gph into c : data x.gph. - AST mode keeps the () of a call with no arguments (display runiform()) and a blank data row between input and end. - Embedded-block placeholders are applied in one pass with line offsets computed once (1,000 mata: lines: 11.3 ms to 2.3 ms for indentation diagnostics). sight parse --json: - Weight words and abbreviations Stata 18 accepts: w..weight, fw..fweight, freq..frequency, aw..aweight, cell..cellsize, pw..pweight, iw..iweight. - foreach ... of var/new/num/loc/glo (three letters or more) report the full list type. - else /* c */ if reports else_if: true. - syntax Level(integer 95) reports default "95"; hover shows it as Level(integer 95). - display runiform() reports runiform() as its argument. * Parse include using/…, program `name', glued using and price[`weight'] as Stata does, and keep label/note text and program-header comments when formatting (#417) Fixes parser regressions since v0.15.1, each checked against StataMP 18: - include/do/run using/setup.do takes the path, not the using keyword - program `cmdname' defines a program closed by its end - #delimit ; program // note, then define p; defines p - `stem'using, `stem'in and `stem'if are one name - price[`weight'] is a subscript, not a weight clause - label variable/data/define, char and note ...: text keeps its if/in/using words, and AST formatting prints it as written - a comment in a program header, or a /// note before an inline mata:, makes AST formatting leave the file as written instead of dropping it - a run of // comments in a #delimit ; statement parses in linear time * Keep Stata console sends from being lost at --more--, while connecting, or behind a long command, and keep polling after a huge burst of output (#416) * Keep the Stata console polling after a huge burst of output, and keep editor sends from being lost at --more--, while connecting, or behind a long command - Automation backend: append a poll's lines without spreading them (a burst of ~200k lines overflowed the stack and stopped polling for good), consume held lines by index, and keep polling after a poll throws, saying so once. - Editor sends go through a new send_line entry (console API v3): at --more-- they wait for the prompt instead of being taken as pager keys; typed keys still answer --more--. - A Stata pane holds each typed send's temp file until its console gives the line to Stata, then deletes it after the usual delay; it deletes it at once if the line is dropped or the pane ends. - The active-terminal commands send to a Stata pane through its queue, so a send made while the pane connects isn't dropped. * Don't let a hand-off's cleanup delete a send's file soon after the pane releases it * Read input data, prefixed mata: and python: openers, and #delimit ; star comments as Stata does (#414) * Read input data, prefixed embedded openers, and #delimit ; star comments as Stata does Co-Authored-By: Claude Opus 5.5 <[email protected]> * Bound the program-header check to the input data region Co-Authored-By: Claude Opus 5.5 <[email protected]> * Test formatting of prefixed mata: lines and #delimit ; input records Co-Authored-By: Claude Opus 5.5 <[email protected]> * Test a * comment after an abbreviated #d ; Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * Print no stray ; for an input with no records under #delimit ; The blank-row check compared line numbers, which under #delimit ; is true for an empty block because the data starts on the input line. Caught by input-data-edge-cases.test.ts once main's #414 was merged in. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
A review before the stable release found four ways the new Stata console (
sight consoleand the Windows Automation pane) loses output or sends. This PR fixes all four.1. A burst of Windows output stopped polling for good. If one poll read about 200,000 log lines (a large
listwithset more off),held_lines.push(...lines)threwRangeError: Maximum call stack size exceeded. The poll promise rejected, no further poll was scheduled, and output and queued commands were stuck after that. Now the backend appends without spreading, consumes held lines by index (so a huge poll isn't quadratic), and keeps polling when an iteration throws, saying so once. I sweptsrc/console/for the same pattern and found one more, the multi-line paste insession.ts.2. Windows deleted a queued do-file before Stata opened it. Say Stata is running
sleep 60000and you send another statement. The temp file's 30 s cleanup started when the send was handed to the pane, but Stata got thedoat about 60 s. Now the pane holds each typed send's file until its console actually gives the line to Stata, then deletes it 30 s later. If the line is dropped (Ctrl+C) or the pane ends first, it deletes the file at once. A cleanup scheduled while the file was held never deletes it, even if it fires after the release.3. An editor send disappeared at
--more--. The pane typeddo "file"plus Enter, sodanswered the pager and an empty line was submitted. Editor sends now come in through their own entry point,send_line(the console runtime API goes to v3). At--more--a send waits, with a note under the prompt, and goes out at the next command prompt, one per prompt. Ctrl+C drops waiting sends. Keys you type still answer--more--.4. A terminal send vanished while a Windows pane was connecting. "Terminal: Do Line or Selection" called
sendTexton the active terminal, and the pane drops input until its session exists. Now, when the active terminal is a Stata pane, these commands go through the pane's queue, the same way the integrated target does. That also gives them fixes 2 and 3.Outside the files I own, there are two small changes in
stata-terminal-manager.ts:type_sendpasses the temp file path to the pane, and a newsend_to_console_pane_terminalexport.Not changed: on macOS and Linux, the PTY backend writes a line straight to Stata's terminal and reports it as given to Stata right away. A send made behind a long command there still has the old 30 s window.
How I proved it: each fix has a regression test that failed before the fix and passes after:
RangeErroratautomation-backend.ts:572;--more--wrote["d\r", "\r"];sendText.The Windows items were proven against the simulated bridge and fake console runtime, not a live Windows Stata. All four gates passed separately on the rebased head:
check:line-endings,typecheck,bun test ./tests(9915 pass, 0 fail) andlint.Created with Claude Opus 5.5 in Claude Code.