Skip to content

Commit 826cc7e

Browse files
Add fileref_source node for %include FILEREF(member) syntax; bump to 0.4.1
Extends include_statement to accept fileref_source (FILEREF or FILEREF(member.sas)) alongside the existing string_literal form. Defined as a lexed terminal to prevent _option_token catch-all from consuming the member parens. Fixes 82% %include miss rate on AHRQ corpus (79 statements, all in fileref form, previously zero resolved). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6ff6f6e commit 826cc7e

10 files changed

Lines changed: 8733 additions & 8589 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grammar.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,21 @@ export default grammar({
556556

557557
include_statement: $ => seq(
558558
$._pct_include,
559-
field("source", $.string_literal),
559+
field("source", choice(
560+
$.string_literal,
561+
$.fileref_source,
562+
)),
560563
repeat($._option_token),
561564
";",
562565
),
563566

567+
// Fileref syntax: %include FILEREF; or %include FILEREF(member.sas);
568+
// Defined as a single lexed terminal so the lexer matches FILEREF(member)
569+
// atomically — longer match beats the plain identifier, preventing
570+
// _option_token's catch-all regex from swallowing the parens first.
571+
// Captured as @import.source in queries; member name is inside the parens.
572+
fileref_source: $ => /[A-Za-z_][A-Za-z0-9_]*(\([A-Za-z_][A-Za-z0-9_.]+\))?/,
573+
564574
// ── LIBNAME ───────────────────────────────────────────────────────────
565575

566576
// Everything after libref kept flat — Ix query finds string_literal by position.

package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

queries/tags.scm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
(proc_step_header
2222
name: (identifier) @name)) @definition.module
2323

24-
; %INCLUDE → import
24+
; %INCLUDE → import (string literal form)
2525
(include_statement
2626
source: (string_literal) @import.source) @import
2727

28+
; %INCLUDE → import (fileref form: FILEREF or FILEREF(member.sas))
29+
(include_statement
30+
source: (fileref_source) @import.source) @import
31+
2832
; LIBNAME → import (library path)
2933
(libname_statement
3034
(string_literal) @import.source) @import

src/grammar.json

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)