feat: grammar fixes and add new studio-highlighting.scm file #34
Merged
davem-intersys merged 11 commits intointersystems:mainfrom Apr 10, 2026
Merged
feat: grammar fixes and add new studio-highlighting.scm file #34davem-intersys merged 11 commits intointersystems:mainfrom
davem-intersys merged 11 commits intointersystems:mainfrom
Conversation
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.
Overview
This PR adds a new
studio-highlighting.scmfile to group nodes the same way studio does for highlighting purposes. Additionally, fixes to the core grammar were added (see below for details)Key Changes
1. Parser and scanner behavior were tightened
The core scanner gained explicit handling for inactive preprocessor blocks and a
broader set of command-like tokens.
common/scanner.haddsPOUND_IF_SPECIAL_CASE*,MNEMONIC, andTAG_END_IFscanner tokens.#if 0 ... #endifblocks are now recognized as a special case so the parsercan treat unreachable code differently and queries can highlight it as
inactive. When #IF 0 happens, iris actually registers everything from that line up to #ELSE ,#ENDIF, and #ELSEIF 1 as a comment (so it is technically valid to write whatever you want within those lines). Additionally, here the #ELSE and #ELSEIF 1 happens 100% of the time, so IRIS treats this the same way as an #ENDIF, and makes it so #ENDIF is optional. There were some cases where someone started a block between the #ELSE and #ENDIF, which caused the parser to break. To fix this, in this special case, the #ENDIF is treated as a special tag if #ELSE has already been seen.
MV*,ZALLOCATE,ZLOAD,ZUSE, and relatedZ*commands.mnemonics, comments between a condition and a following block, and
argumentless loop/command termination.
2. Routine Grammar Changes
Before, it was valid to have anything in the first three lines (would return compiled_header token). Now, the second line must be %RO (as all compiled versions have this) to get the compiled_header token. Valid options are
compiled_header, routine header (ROUTINE name [type = ]), or an objectscript statement (added this as it is allowed in studio).objectscript_routine/grammar.jsintroducesroutine_definitionand allows asource file to begin with a compiled header, a
ROUTINEdefinition, or atop-level statement.
objectscript_routine/src/scanner.csimplifies the compiled-header andROUTINEdetection path and keeps routine-specific lexing active without theolder staged gating flags.
rtn_dothandling is now part of the routine grammar extras, which bettermatches real
.mac/.rtncontent.README.mdandCONTRIBUTING.mdwere updated to describeobjectscript_routineas a routine-file grammar instead of aroutine-header grammar.
3. Expression, core, and UDL grammars were broadened and cleaned up
Grammar Changes include:
expr/grammar.jsform (allows ( and ) also)
$BITLOGICas a separate built in function, as this one function allows operators that normal expressions don't$SYSTEM.*chaining (as the last item is allowed to be an oref chain expr, not just a regular method)oref_parametercore/grammar.jsZBREAKparsing with the new mnemonic and option tokensNEW(since a macro can evaluate to a local var)MERGEarguments toset_targetZLOADGOTO/argument parsing casesudl/grammar.jsreturn_typefor property, relationship, and projection typingtypenameparsing forType(...) Of ...highlighting
common/keywords.jsandcommon/identifiers.jswere adjusted to support thenew aliases and identifier behavior.
4. Studio-specific highlighting
studio-highlights.scmfiles were added for:objectscript/queries/objectscript_routine/queries/udl/queries/for routine and UDL bindings.
STUDIO_HIGHLIGHTS_QUERYconstants in:bindings/rust/lib.rsbindings/rust-routine/lib.rsbindings/rust-playground/lib.rsmanifests and staging scripts.
5. Standard highlight queries were updated to match the new tree shape
The existing
highlights.scmfiles acrossexpr,core,udl,objectscript, andobjectscript_routinewere refreshed.These changes include:
parameter_namehighlighting moved tooref_parameterzbreak_command_option,tag_end_if,command_keyword,keyword_zload, anddotted_statement#if 0regions can now be tagged as inactive codereturn_type-based typecleanup
.tsqueryrc.jsonwas updated at the same time to document new capture namessuch as:
comment.inactivepunctuation.special.dotsvariable.member.orefvariable.member.sqlpunctuation.bracket.json6. Query sync and packaging workflows were updated for the new assets
The repo now treats Studio highlight files as related, but separate, artifacts.
scripts/sync_queries.pystill manages the canonical trio:highlights.scmindents.scminjections.scmstudio-highlights.scmis now explicitly excluded from the normal composedquery sync and Python query-copy verification path.
scripts/rust_routine_crate.shandscripts/rust_playground_crate.shnowcopy
studio-highlights.scminto staged crate directories.cargo_readme.md,cargo_readme_playground.md, andcargo_readme_routine.mdwere updated to document the new exported queryconstants.
Testing
This was tested on many real rtn, mac files as well.