Skip to content

Read the lines after input as its data, up to end, instead of as statements - #396

Merged
jbearak merged 2 commits into
mainfrom
refactor/unexpected-end-from-ast
Nov 5, 2026
Merged

jbearak merged 2 commits into
mainfrom
refactor/unexpected-end-from-ast

Conversation

@jbearak

@jbearak jbearak commented Nov 5, 2026

Copy link
Copy Markdown
Owner

input x y reads the lines after it as data, up to a line whose first word is end. Sight parsed each data line as a statement instead: john 30 became a command named john, and `v' in a data line was reported as an undefined macro, although Stata reads data literally. Checked in StataMP 18:

  • "xv'"` is stored as is, with the macro unexpanded;
  • end foo, end // done, an indented end, and end; all end the data;
  • inside a program definition, the data's end ends the program instead, so there is no data there.

Changes:

  • Lexer: keeps the data lines as one INPUT_DATA token when input (or inp, inpu) is at command position outside a program, prefixes included (quietly input). It also lexes the end line itself, so text after end (end /*, end ") can't open a comment or string that swallows later lines.
  • Parser: attaches the data to the input command, whose range now runs through end.
  • Formatters: both modes keep the data lines as written.
  • Send to Stata: sends input with its data from the header or the end line.
  • Docs: sight parse --json and Send to Stata docs updated.

This is groundwork for reporting an end that closes nothing from the AST; that change comes in a follow-up PR.

Proof: tests/unit/input-data.test.ts (both formatter modes) and a Send to Stata detector test. sight check over Stata's 3,780 base ados is byte-identical to main (36,571 diagnostics), as expected, since ado input is inside programs. Typecheck, lint, and bun test ./tests pass (9652 tests).

Reviewed with sol-loop: 2 rounds with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in T3 Code.

jbearak and others added 2 commits November 5, 2026 18:06
…ements

`input x y` reads the lines after it as data up to a line whose first
word is `end` (StataMP 18), but Sight parsed each data line as a
statement: `john 30` became a command named john, and `` `v' `` in the
data was reported as an undefined macro, though Stata reads data
literally. The lexer now keeps the data lines as one INPUT_DATA token,
the parser attaches them to the input command, whose range runs
through `end`, both formatters keep them as written, and Send to
Stata sends input with its data. Inside a program definition there is
no data: Stata ends the definition at the data's `end`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e before lexing it

`quietly input x` reads data like `input x`, and Stata discards the
rest of the line after the data's `end`, so a `/*` or a quote there
must not open a comment or a string that swallows the next lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 68 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 2261ec96-f279-4e58-b391-50e6d7c59220
Commits

Reviewing files that changed from the base of the PR and between d26970b and 8f3c840.

Files selected for processing: 10

  • client/src/send-to-stata/statement-detector.ts
  • docs/cli.md
  • docs/send-to-stata.md
  • src/formatter/indentation-analyzer.ts
  • src/lexer/index.ts
  • src/parser/index.ts
  • src/pretty-printer/index.ts
  • src/types/index.ts
  • tests/unit/input-data.test.ts
  • tests/unit/send-to-stata/statement-detector.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jbearak
jbearak merged commit 07ed564 into main Nov 5, 2026
16 checks passed
@jbearak
jbearak deleted the refactor/unexpected-end-from-ast branch November 5, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant