Repository navigation
Read the lines after input as its data, up to end, instead of as statements - #396
Merged
Merged
Conversation
…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]>
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 6 minutes. View limit details
|
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.
input x yreads the lines after it as data, up to a line whose first word isend. Sight parsed each data line as a statement instead:john 30became a command namedjohn, 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 indentedend, andend;all end the data;endends the program instead, so there is no data there.Changes:
INPUT_DATAtoken wheninput(orinp,inpu) is at command position outside a program, prefixes included (quietly input). It also lexes theendline itself, so text afterend(end /*,end ") can't open a comment or string that swallows later lines.inputcommand, whose range now runs throughend.inputwith its data from the header or theendline.sight parse --jsonand Send to Stata docs updated.This is groundwork for reporting an
endthat 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 checkover Stata's 3,780 base ados is byte-identical to main (36,571 diagnostics), as expected, since adoinputis inside programs. Typecheck, lint, andbun test ./testspass (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.