Skip to main content

MATLAB tree-sitter parser

Project description

MATLAB grammar for tree-sitter.

There are screenshots at the end of this README :)

This parser has the objective of generating a tree that is as correct as possible (but sometimes just convenient) with what MATLAB itself executes. It is not intended only for syntax highlight, but also to be used by scripts to whatever it may be needed. In fact, I wrote it because I'm a Neovim/Doom Emacs user and love having text-objects, and was really missing a text object for matrices rows/cells.

Being as correct as possible means that some things are done correctly, for example:

  • Commands are parsed the same way MATLAB does it, by treating arguments as literals, grouping them correctly and only starting comments when allowed. It should perfectly match what MATLAB does.

  • Assignment has its own token, and multiple-variable assignment is NOT an assignment to a matrix (and returning an error is the correct thing to do, as it allows the user to see that something is off with the highlight, meaning something is probably off with the code):

% (assignment (multioutput_variable (identifier) (identifier)) (identifier))
[a,b] = d

% this is WRONG:
[a;b] = d
  • Inside a matrix, 1 + 1 and 1 +1 are different things:
a = 1 + 1 % 2
a = 1 +1 %2
[1 + 1] == [2]
[1 +1]  == [1 1]

Being convenient means that sometimes the difference between what is acceptable and what is not acceptable lives in the semantics, so we can't know. In such cases I just accept semantically wrong but syntax correct things and group them in the same token (first example). I do the same when the overhead of generating a specific token would not really pay off (second example).

  • Function calls and Matrix Indexing are the same in MATLAB: A(1) can be any of them and you cannot tell them apart unless you know for sure what A is referring to. So for convenience I just generate a function_call for them and also for cell indexing A{1}. The "problem" with that is that this is a valid indexing but an invalid function call: A(:). However I don't distinguish at all and say that all of them are function_call.

  • Function definitions, when inside a class, accepts a special syntax for the name of the function, allowing it to be preceded by either get. or set., like function get.name(). I could have a method_definition that would allow that to only be valid in the class context, but I doubt that would be worth it. So any function anywhere can have those and be recognize as correct still. Given the existence of external method definition, maybe that is even the correct thing to do, since we don't know if the current file is inside a special class folder.

Installation

This parser is available in the following editors:

Editor Plugin Highlights Folds Indents Code Format Injections Locals
Emacs Emacs-MATLAB-Mode
Helix Builtin
NeoVim nvim-treesitter

The columns have the following meaning:

  • Highlights: supports syntax highlight
  • Folds: supports code folding
  • Indents: supports code indenting, which adjusts the leftmost whitespace on each line.
  • Code Format: indent includes code formatting that standardizes the spacing of language elements within code lines, aligns matrix columns, adds missing commas within cells and matrices, etc.
  • Injections: supports embedding the language into another language (i.e.: MATLAB code blocks inside Markdown or org-mode)
  • Locals: supports identifying variables/functions/etc scope

Known issues

  • There is a conflict between numbers and element-wise operators that will cause a wrong parse if there is no space between the number and the operator. For example, 1./a will be interpreted as 1. / a instead of the correct 1 ./ a. This problem does not happen if there is a space between the number and the operator.

Screenshots

First Screenshot Second Screenshot Third Screenshot

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_matlab-1.2.13.tar.gz (181.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_matlab-1.2.13-cp314-cp314t-win_arm64.whl (88.6 kB view details)

Uploaded CPython 3.14tWindows ARM64

tree_sitter_matlab-1.2.13-cp314-cp314t-win_amd64.whl (89.9 kB view details)

Uploaded CPython 3.14tWindows x86-64

tree_sitter_matlab-1.2.13-cp314-cp314t-win32.whl (89.3 kB view details)

Uploaded CPython 3.14tWindows x86

tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_x86_64.whl (123.3 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_aarch64.whl (129.6 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (131.9 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (124.7 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

tree_sitter_matlab-1.2.13-cp314-cp314t-macosx_11_0_arm64.whl (92.0 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

tree_sitter_matlab-1.2.13-cp310-abi3-win_arm64.whl (85.9 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_matlab-1.2.13-cp310-abi3-win_amd64.whl (87.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.2.13-cp310-abi3-win32.whl (86.5 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_x86_64.whl (120.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_aarch64.whl (126.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.13-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (129.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_matlab-1.2.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (121.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

tree_sitter_matlab-1.2.13-cp310-abi3-macosx_11_0_arm64.whl (92.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file tree_sitter_matlab-1.2.13.tar.gz.

File metadata

  • Download URL: tree_sitter_matlab-1.2.13.tar.gz
  • Upload date:
  • Size: 181.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tree_sitter_matlab-1.2.13.tar.gz
Algorithm Hash digest
SHA256 4288fb0163e782bf5c6aa255d83e7444a9cbc8a98748e5b92fda23a746d3233c
MD5 36baf197640d28a35757f1ed176ccf06
BLAKE2b-256 2e7769be0eda89c5eebec9a91b422cccb39099c9b9ada9ba63ef0284c5d7a279

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13.tar.gz:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 c292fce2857a70661910eca85bb20f203d185d1032cd2fd9a2928a3476159a06
MD5 9200c9de43968d44bde3414e6f9a5960
BLAKE2b-256 0e00452c02b2de084a57ee744d7d4cf7a5a1073e8f8e15fe4bfab77139729a3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-win_arm64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 5e828253b0ed0ac5966cebec42448d1548ec515a0a14eba96a193f78a913c5ed
MD5 8e261319004768581d4893f6d134e869
BLAKE2b-256 32eab8c4b267679508c526e83e77ef4da3624c158c6ef709cc1a1fff0194e627

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-win_amd64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 d6f14e9017094a7ed37a2d8d2671d6e95b29a1cd3a6dd2e26a7c05468412d231
MD5 021749bb5748e561ac2b62ac7377470e
BLAKE2b-256 cc7407ec7c0bf3591167a09992df91e781279c4f80e53daac3a64bcf3be30970

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-win32.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 318d9ad4d3320283a3bc26de59cf5c6721647b012331c241411b44ec6c0b12c6
MD5 d3c256d02546b790f06098182c037677
BLAKE2b-256 8bd4254b22ab534a55582d66cafa8dbd14450bff705001f7021c67041658c4d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_x86_64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0b182832786dfd3fc9a16fb7fde1e079d39a4747f9d344a7f68c05c3105047bb
MD5 0811c7e004926abecf250d7721746660
BLAKE2b-256 280a55bcaa97afe71db8a45feec9368a249a1275e6a57f54aeebc7867d560dfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-musllinux_1_2_aarch64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ee93af2be36a31d780e76d96df6016905f5084a2c4f82bc744908788a1bc115c
MD5 e346d2fa619165a08db58a0e1001975b
BLAKE2b-256 099ce24432381aebb8180a529cba6d0f18f2b0161847228944f05a1ed2349f6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9cab6a510a726897d3d236370d135ce3bc2381f28f98e9c2c929869a93846cea
MD5 5288b8540fa9695cbe713d94e50e377d
BLAKE2b-256 503386fa8a1ce8d8cd406a836ea4e4b06d8e1a08f14bb51c7a295d0e4bac1878

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a52b75469f18a26fbb36d8016346c758de465707007b75f9c3bc4fad95cc1e10
MD5 db12500a518dc3d38e987d1b5be492d4
BLAKE2b-256 335e2c78859d5b660791aa4bd81c7156176a0cbf359f79d5c302b09e5dca37fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 578123df90286900306ef28360e20c759c08ff4002ce3994d2526fbb663d75c8
MD5 1e93ec54d1e93a0e468af96b6bd8cdda
BLAKE2b-256 d8e38c8f81b5fafde4c9cea6f4ea34bc15ff76e68a007b9dfeb2f8327a634eac

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-win_arm64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1436229db43d2e363aa2aa15a57c53e92708bd44e176293be079a3dad6be0d88
MD5 4ad83bf61046899ad98fe71592394ef2
BLAKE2b-256 92d3e808393be9cc2df8f1ff8d7876bbbc43049cbab741721edaa64b5e321e08

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-win_amd64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 5b277785a23b9ff21d2d8fa70230d1c5f79740d53149bb9c1762660e9e1e9dda
MD5 bde26085c29311f4d40556fabc97bd33
BLAKE2b-256 ae397ce6ddd4fe5c6ea17d0fb95c149b0aea96bc2a2d4a6e55829d382060f856

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-win32.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fda2591cbbe8c316975cff5205fbaedb84a5502097e2c292b007b4dd086d83ec
MD5 e81fcffb927db7f89af7f79697684d6d
BLAKE2b-256 b8e4a1ad394c9573761903e92d8136432c65ca62f88b00c8e55a3adece5b4d83

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1f025acc079468cac3c62c55c70e15dc55b667dda7cfee9e1e2607c93688de5c
MD5 aa72bb2a0d60f0e980e8cba689a7801a
BLAKE2b-256 c52dfa6a0c070cb5584fa3e1d12a1c38867b8912136c61f0095a6fafb134211c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ae4ca2375dcdfa92558ec50e9beae069710cb23b3819f904ac63c0ca6fa5711e
MD5 140e802dc661b13bd34269bb3a0f3cfe
BLAKE2b-256 226a2c1cd3e1d2b1d59ab364868a84985b890d1bc1b388d737fb4e7e4eb41081

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 bdd10820d13294ad322e9ee077905097279f35e8ba4148dccbde1b1cf63c6c81
MD5 460165feb2096b1c0ffa864d2d4a1aa7
BLAKE2b-256 3d00fc80fc4fdeff62aa1dde31b4167032b2d5d6a6037bb7925c854cf49ae0e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_matlab-1.2.13-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.13-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 471a3ffbf3fba571e781a28c5e650ee201d0776aef0197d25bcb0ee04fa04785
MD5 019f5b0bf3be8f4296e0052b36f277bb
BLAKE2b-256 27a6a3e494d424791a5c40bc84d750a212c6bcd5d92033e1a6622877b6b174a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.13-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on acristoffers/tree-sitter-matlab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page