Skip to content

feat: add routine grammar, update core grammar, update highlighting#29

Merged
davem-intersys merged 5 commits intointersystems:mainfrom
hkimura-intersys:routine-grammar
Mar 20, 2026
Merged

feat: add routine grammar, update core grammar, update highlighting#29
davem-intersys merged 5 commits intointersystems:mainfrom
hkimura-intersys:routine-grammar

Conversation

@hkimura-intersys
Copy link
Copy Markdown
Collaborator

@hkimura-intersys hkimura-intersys commented Mar 20, 2026

Overview

This PR adds a new grammar, objectscript_routine, which parses routine headers, providing syntax highlighting for .mac, int, and .inc filetypes. Additionally, this PR solves a few bugs and updates highlighting.

Key Changes

  • Added routine grammar
  • Added ability to parse a special case of do argumentless commands
  • Fixed for command parsing to be able to parse a special case of argumentless for loop blocks
  • Allow variadic args as a method parameter in method definitions
  • Update highlighting
  • tree-sitter-objectscript rust crate now includes the routine grammar and support for .mac, .inc, .int
  • fixed bug in sync_queries script that was causing duplicates
  • updated git hook to automatically run the lint/query validation steps and sync queries if they don't match.

The Routine Grammar

The routine header allows Type to be either mac, inc, or int.
image

This grammar provides highlighting for routines, and was added to the rust tree-sitter-objectscript crate and tree-sitter-objectscript-playground crate.

Special case of do argumentless commands

There is a special case of do commands where you can have something like:

i x d  d arr(.y,.z) GOTO filename 
. set x = 2
. w hi

What this means is: run the dotted statements first, and then run the commands that are on the first line after the do command. Before, this syntax was not supported in our grammar. Now, it works as expected:
image

This case has been added as a test case in core.

Special case of for loop argumentless blocks

In the case where the is a comment immediately after a the keyword for, it used to get registered as the old for version,
making it so the block version would fail:
image

This PR fixes this, and it is parsing as expected now:

image

Variadic Args in Method Definition

Before, variadic args were only allowed to be passed when calling a method, now they are also allowed in the method definition.
image

Update Highlighting

A big part of this PR is also to update highlighting. Some changes include:

  • command keywords (if, set, etc) will have a different color than other keywords (method, class, etc)
  • there are also subgroups within the command keywords based on behavior (conditional, directive, etc)
  • before, highlighting of comments weren't working if the comment was right after an argumentless command (and on the same line) because the scanner just ate the comment. This is now fixed.
  • variables starting with % are colored differently than other variables
  • macro function vs constant is differentiated
    Before Changes:
image image

After Changes:
image
image

Sync Queries Bug

Before, a bug was causing the highlights from expr to get copied twice into the udl highlights, since udl is composed of expr and core, and the script was accidentally copying the entire core highlights (which also includes expr highlights) rather than just the core specifc highlights. This is fixed, now only content within LOCAL blocks are copied.

Git Hook Automation

Once someone runs make installhooks and has the git hook on their local computer, the git hook will automatically run on a commit, checking that queries in the python binding match the highlights in the grammar folders, and update the python binding if needed. It will also run a lint check and all of the parser tests.

@davem-intersys davem-intersys merged commit 6167e1d into intersystems:main Mar 20, 2026
11 checks passed
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.

2 participants