Skip to content

feat(data): complete the SAS macro vocabulary - #7

Merged
allanbowe merged 1 commit into
mainfrom
feat/complete-macro-data
Oct 1, 2026
Merged

allanbowe merged 1 commit into
mainfrom
feat/complete-macro-data

Conversation

@sasjs-dev

@sasjs-dev sasjs-dev Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the SAS macro vocabulary in the published data. macroStatements goes 32 -> 37 entries and macroFunctions 65 -> 89.

Why

The macro groups were built from the extension's keyword files alone, and those carry only part of the vocabulary. Neither SASMacroStatements.json nor SASMacroFunctions.json lists %INDEXC, %INDEXW, %QINDEX*, %TRANWRD, %TRANSLATE, %TRIMN, %QBQUOTE or %QDEQUOTE, and neither lists the %BY, %TO or %INC keywords. A consumer that needs to tell a SAS-provided macro from an undeclared one - the noUndeclaredMacros rule in @sasjs/lint - is left with a list that reports shipped macros as unknown.

What changed

A second upstream source. The language server ships the same vocabulary a second time under server/pubsdata/, in a different shape. It is the same upstream repo, so it is fetched and merged rather than duplicated:

  • server/pubsdata/Functions/en/macro.json adds %KCMPRES, %KINDEX, %KLEFT, %KLENGTH, %KSCAN, %KSUBSTR, %KUPCASE, %QKCMPRES, %QKLEFT, %QKSCAN, %QKSUBSTR, %QKUPCASE and %VALIDCHS;
  • server/pubsdata/Statements/en/macro.json adds %COLORMAC and %HELPCLR.

scripts/fetch-upstream.mjs now mirrors the upstream repo path under .upstream/, so a group can read a file from either directory, and scripts/build.mjs reads the pubsdata shape alongside the keyword shape. The pubsdata descriptions become hover text.

A documented supplement. scripts/supplements.mjs holds the names the SAS Macro Language Reference documents and neither upstream copy carries: %BY, %TO and %INC; %INDEXC, %INDEXW, %QBQUOTE, %QDEQUOTE, %QINDEX, %QINDEXC, %QINDEXW, %TRANSLATE, %TRANWRD, %TRIMN; and %QKLOWCASE, which upstream ships truncated to %QKLOWCAS in both SASMacroFunctions.json and SASAutocallMacros.json.

An upstream row always wins, so the supplement shrinks on its own as upstream fills the gaps - it is a bridge, not a second source of truth.

Verification

  • npm test: 15 tests pass, including a new one asserting the macro groups carry the names above.
  • npm run lint (prettier): clean.
  • A fresh npm run fetch -- --ref <pinned> plus npm run build leaves data/, provenance.json and src/groups.generated.ts unchanged, which is the condition CI enforces.
  • Only the two macro groups moved; the other 20 groups are byte-identical.

The macro groups were built from the extension's keyword files alone, which
carry only part of the vocabulary - no `%INDEXC`, `%TRANWRD` or `%TRIMN`,
and none of the `%BY`, `%TO` or `%INC` keywords. A consumer that needs to
tell a SAS-provided macro from an undeclared one is left with a list that
reports shipped macros as unknown.

Two more sources close the gap:

- the language server's `pubsdata` macro lists, which are the same upstream
  repo and a different shape, and carry the DBCS `%K*`/`%QK*` functions and
  `%COLORMAC`, `%HELPCLR` and `%VALIDCHS`;
- `scripts/supplements.mjs`, a documented list of the names the SAS Macro
  Language Reference documents and neither upstream copy carries. An
  upstream row always wins, so the supplement shrinks as upstream fills in.

The fetch now mirrors the upstream repo path under `.upstream/`, so a group
can read a file from either directory, and the build reads the pubsdata
shape alongside the keyword shape.

`%QKLOWCASE` is added because upstream ships that name truncated to
`%QKLOWCAS`.
@allanbowe
allanbowe merged commit 4407b1a into main Oct 1, 2026
2 checks passed
@allanbowe
allanbowe deleted the feat/complete-macro-data branch October 1, 2026 18:20
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 0.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant