Skip to content

Read prog def and the other abbreviations Stata accepts for program define as program definitions - #402

Merged
jbearak merged 2 commits into
mainfrom
fix/program-abbreviation
Nov 6, 2026
Merged

jbearak merged 2 commits into
mainfrom
fix/program-abbreviation

Conversation

@jbearak

@jbearak jbearak commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Stata's base ados define programs as prog def roctab, rclass (51 times) or prog define (5 times). Sight recognized a definition only when the command was spelled program in full. So those programs weren't parsed: their bodies were read at top level, each end was reported as "Unexpected end", and their if blocks drew false "Missing closing brace" errors. This was the cause of most of the "Unexpected end" diagnostics left after #398.

Checked in StataMP 18: pr define, pro de, prog and progr defi define programs. p define is "command p is unrecognized", and program d p6 isn't a definition, so define abbreviates to de.

  • PROGRAM_COMMAND_NAMES (pr … program) is now shared by the lexer's open-definition tracking, the parser's dispatch, and its error recovery. The parser already handled de … define. prog drop x and the other subcommands stay commands.
  • The outline selects just the program's name after an abbreviated header. Its regex is now exact-case; it used to match case-insensitively.
  • The grammar highlights prog def name and pr drop name.
  • Auto-indent fires after prog def name. In language-configuration.json, the lone-{ alternative was written \|, a literal pipe, so it never matched; that's fixed too.

Proof: on the 3,780 base ados vs main, 83 diagnostics are removed: 57 "Unexpected end", 25 false "Missing closing brace for if statement" and 1 OUT_OF_SCOPE_SYMBOL. 28 are added, all OUT_OF_SCOPE_SYMBOL in _stcurv.ado, where atlist is used in programs that never define it; that's an existing rule now reaching code scoped to its program. Each new test fails before its change. Typecheck, lint, and bun test ./tests pass.

Not covered: 4 "Unexpected end" remain, from program `cmdname' (a program named by a macro) in dtaverify_11x.ado. That needs separate handling of macro program names.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in T3 Code.

@coderabbitai

coderabbitai Bot commented Nov 6, 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 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 71 included PR review attempts over the past 7 days set your current allowance at 1 review 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: 9f434ac8-5491-463a-a0ea-8aa42b11d67b
Commits

Reviewing files that changed from the base of the PR and between f962176 and f4e6b1c.

Files selected for processing: 10

  • client/language-configuration.json
  • client/src/language-config.ts
  • client/syntaxes/stata.tmLanguage.json
  • src/lexer/index.ts
  • src/parser/index.ts
  • src/providers/symbols.ts
  • src/utils/program-definition.ts
  • tests/unit/program-abbreviation.test.ts
  • tests/unit/symbols.test.ts
  • tests/unit/textmate-grammar-program.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jbearak
jbearak merged commit 73fcd48 into main Nov 6, 2026
16 checks passed
@jbearak
jbearak deleted the fix/program-abbreviation branch November 6, 2026 03:13
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