Add MATLAB syntax highlighting - #679
Open
MingqiZhang0 wants to merge 1 commit into
Open
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.
Summary
Adds MATLAB syntax highlighting support to Focus.
This introduces a dedicated MATLAB tokenizer and wires it into Focus's language selection, comment commands, and color preview.
Highlights
The tokenizer supports:
true/falsevaluesi/jsuffixes%line comments and%%section comments%{ ... %}block comments with MATLAB's standalone-line delimiter rules...line continuationfunction foofunction foo(x)function y = foofunction y = foo(x)function [a,b] = foofunction [a,b] = foo(x)Special handling is included for MATLAB's
'ambiguity between character vectors and conjugate transpose.A quote directly following an expression is treated as transpose, while a quote preceded by whitespace starts a character vector.
Examples:
.mfile associationFocus currently uses
.mfor the existing Objective-C highlighting path, so this change intentionally does not globally remap.mfiles to MATLAB.MATLAB projects can opt in explicitly:
A commented example has been added to the default config.
Comment commands
%.%{and%}have standalone-line requirements.Validation
A fresh Jai compilation was not performed, because a Jai compiler was not available locally.
Instead, the MATLAB tokenizer logic was ported rule-for-rule to a standalone Python test harness for behavioral validation.
The Python tokenizer and a small Tkinter editor shared the same tokenizer implementation, allowing both token-stream regression tests and visual/live-edit behavior to be checked without using a third-party MATLAB lexer.
Validation performed with the Python surrogate:
The visual/live-edit tests included cases such as:
A'A.'A''[seq 'def']{A 'text'}[A' 'text']true'false'A'toA 'and back%}in a block commentThe Python test harness is only a behavioral surrogate for the tokenizer.
It does not prove that the Jai source compiles, and it is not an actual Focus runtime test.
Current verification status:
Scope
This PR only adds MATLAB syntax highlighting.
It does not add:
.mlxsupport.mcontent detectionScreenshot
This screenshot comes from a standalone Python editor that ports the MATLAB tokenizer rules for visual demonstration only. It is not a Focus runtime screenshot. Because a Jai compiler was not available locally, the Jai implementation itself could not be compiled or tested.