fix(grammar): use fixed-length look-behind in FunC function definitions - #344
Merged
i582 merged 1 commit intoJun 22, 2026
Merged
Conversation
The function-definition rule used a variable-length look-behind,
`(?<=^|[;{]\s*)`. Oniguruma accepts it, so VS Code highlighting is
unaffected, but engines that require fixed-length look-behind reject it
(for example the grammar compiler GitHub Linguist uses), which prevents
the grammar from being reused there.
Split the assertion into two fixed-length look-behinds, `(?<=^)` and
`(?<=[;{])`, and move `\s*` into the match. Behavior is unchanged: a
function name is still matched at the start of a line, or after `;` or `{`
with optional whitespace.
Member
|
Hey! Sounds great, thank you! |
Contributor
Author
|
Thanks! Glad it helps. |
i582
approved these changes
Jun 22, 2026
0xnirapod
added a commit
to 0xnirapod/linguist
that referenced
this pull request
Jun 22, 2026
Switch the vendored grammar from the archived tolk-vscode to TON's maintained ton-language-server, which tracks current Tolk syntax. It became usable in Linguist once the FunC grammar's variable-length look-behind was made fixed-length upstream (ton-blockchain/ton-language-server#344).
6 tasks
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.
What
The FunC TextMate grammar's function-definition rule uses a variable-length look-behind:
Why
Oniguruma (used by VS Code) accepts this, so editor highlighting is unaffected. But regex engines that require fixed-length look-behind reject it. GitHub Linguist's grammar compiler, for instance, fails with:
That blocks
func.tmLanguage.json(and with it the rest of the ton-language-server grammars, which compile as a set) from being reused for syntax highlighting on GitHub.Fix
Split the assertion into two fixed-length look-behinds and move
\s*into the match:Behavior is unchanged: a function name is matched at the start of a line, or after
;or{with optional whitespace. Verified locally by compiling the grammars with Linguist's grammar compiler. All five now compile cleanly.