Skip to main content

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

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.3.1.tar.gz (172.1 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.3.1-cp314-cp314t-win_arm64.whl (83.5 kB view details)

Uploaded CPython 3.14tWindows ARM64

tree_sitter_matlab-1.3.1-cp314-cp314t-win_amd64.whl (84.2 kB view details)

Uploaded CPython 3.14tWindows x86-64

tree_sitter_matlab-1.3.1-cp314-cp314t-win32.whl (83.7 kB view details)

Uploaded CPython 3.14tWindows x86

tree_sitter_matlab-1.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl (117.8 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

tree_sitter_matlab-1.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl (123.6 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.3.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (125.8 kB view details)

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

tree_sitter_matlab-1.3.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (119.1 kB view details)

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

tree_sitter_matlab-1.3.1-cp314-cp314t-macosx_11_0_arm64.whl (86.6 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

tree_sitter_matlab-1.3.1-cp310-abi3-win_arm64.whl (81.0 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_matlab-1.3.1-cp310-abi3-win_amd64.whl (81.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.3.1-cp310-abi3-win32.whl (81.1 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.3.1-cp310-abi3-musllinux_1_2_x86_64.whl (115.0 kB view details)

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

tree_sitter_matlab-1.3.1-cp310-abi3-musllinux_1_2_aarch64.whl (120.8 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (123.2 kB view details)

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

tree_sitter_matlab-1.3.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (116.3 kB view details)

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

tree_sitter_matlab-1.3.1-cp310-abi3-macosx_11_0_arm64.whl (86.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.3.1.tar.gz
  • Upload date:
  • Size: 172.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tree_sitter_matlab-1.3.1.tar.gz
Algorithm Hash digest
SHA256 91a2ab61a6179b8aec0216f18f1c1eb4e1409b768641b9c661bab434648bb54d
MD5 4c8f268b934a3e889cb035b7724fc256
BLAKE2b-256 c604be954b2edb5b57648d91d4412e225e361e9c37ac22ce6c45d78713a9b744

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1.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.3.1-cp314-cp314t-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 d13490be96978603f03d9decbb3e2216108b97b3ab434a7709c00278a5afacfd
MD5 4fd6f0000de49b0439baac9f5ada1953
BLAKE2b-256 999171d6470bbe5433c1320b0060b66a30e4b100eb64f4c034bed97790966283

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 b678a165ea792dc3a731580d7edeb838d29c5c95b475fe8bc840752afdc2e9b8
MD5 7b82e75d50c5a4b0772df232ad474f02
BLAKE2b-256 04b4c02832e71e806bff22d872d168f454d95e38da97d9516f284f662c7f6e27

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 5afe8ee1ecf3314bb7e111b34ae70bd53289b417059866c145c6e11193a594c3
MD5 a084422ab06052a5d6a062a1306a8de4
BLAKE2b-256 91df24297ff094dbf66e4aebd53a877302b793412748c291481c409c616bdd44

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3173e14a34e82f13304cd4ae066aad7250bc73b0c855e2be96e889673b8e1f5c
MD5 280cfd0034e9c4ed58f86d1d16a9667d
BLAKE2b-256 2bb369bde9098b0fb3b605e975b4cc9144202fe45a8617e704bf9bff45b17e87

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 955acf4ad3e7b9a4ec84e14dd8d6c42596a45d36d5f6d1a8fd9fdc68b2970dc3
MD5 da57f96267194df0f068d6fc9e60da7e
BLAKE2b-256 a66ae7def13d2f86ba6ae735dd3ea76d62ebc726d8d7dd626e3db1691fb322fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bde730be2a387afc3308ae2aa720ba8d11f91c5c8183acadf149bc427c63bcf8
MD5 eb9c2eaaeace91a2b13b684057ff8621
BLAKE2b-256 1b432d5eb367db854e41417c2dfc1ca549e00f0d6de14dbbcd2221b572831136

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-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.3.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5bd17ef2ad965867d70af8e6be245e6886e5e8d115f66a2aa155380884a65252
MD5 0410b6f0375926c507732e28adee430e
BLAKE2b-256 2fb423fccc18ca1c8640476795223e49fe95cfe557f07bde10fd4b82e3dc043a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4c06388d5334ef98d2f7cb40f93d578f3eb66cd8316a5305a59757c256d9060
MD5 9e24754192ef480a08d2a89318b78672
BLAKE2b-256 b3d3330d3500e0323d56367375fb07b41182ab86fc1f45be0f086250fca23b59

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 325b4af0332ed2e13158d866245974f9f61ad817be159d5245692abaff3bb34e
MD5 7969ae2adabc30c5396a71ba0840f0ff
BLAKE2b-256 b39455f785a562baf807fddffe4d0208138fb73351eee2a20fd0dc3f65a795bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 505d5efdcbd1d76b7134eb7e79727265135c92f2cadbe119930604b5c65fdb46
MD5 b89f96edf1a708405685f6f65f4bb836
BLAKE2b-256 525bf3151a2c407c0776a8c6d22d06bc727c813d755e3dc7cda3819f7f8ae2e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 bf2f24efcceb670828d4a8d82c5a551bd77e4752b0f2913d72145fc2b5380de9
MD5 949a91bb62a289b4b64b73eb4285a536
BLAKE2b-256 776be0fc1b2ecd8e33c11ef82dacaa8e4f48c768bff29b987dce16206166b726

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6a789cf1ed450965f28c476a305c407ff2f0692a336d72fd8ea86a9221b6701f
MD5 4b9206045d4d3012b2894c1cca6901eb
BLAKE2b-256 7ceabccd684fc87b7d4ae6b5375405c97a71518c3d1ab401cc7f29ca0b8d8cd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 14e4386c054507d55d0f5d7d88e53b990967a0ef29146fcc77af0ed5995b49e4
MD5 d1e0ab8086bb0647ccd34e9d0ecff30e
BLAKE2b-256 768a35d394daf205c758a9a0cb375638e5945c290b4200f7b80479d27479acc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 52ada1a896da00cc6e3c918e5548e0b22dd5dcc3cf2ecf061135af45de13d74a
MD5 b1f3e5a6d208e822c5a67db215e03e1a
BLAKE2b-256 d7f60b44ab0452eec5a3d21c33009e58a3447e93a16545d1fa6f2ab491f6c163

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-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.3.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 78f79557f6be5e98d3ba4aa76f655efaab1d5c21dea4127ccd7fe25e20415cf4
MD5 22375782ee4474576b38baea3d63149c
BLAKE2b-256 05ce5e8f5fb357426ec96762a3f063e053a8fefcfde7981f1f28016068f7f2e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.3.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.3.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd080613d88e184c389a8026ff176c3b5a30cd164000ae0f121d5086794afa89
MD5 67f3d06016b04b1b4761ba3f1de4b83e
BLAKE2b-256 7fecd7f27aa3dd0aed3a9bcdfd3f765d28ee4fba1b2473ca8d3e4c3f39eff78e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.3.1-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.

Release history Release notifications | RSS feed

This release

1.3.1 This release

17 files

1.3.0

17 files

1.2.13

17 files

1.2.12

17 files

1.2.11

17 files

1.2.10

11 files

1.2.9

11 files

1.2.8

11 files

1.2.7

11 files

1.2.6

11 files

1.2.5

11 files

1.2.4

11 files

1.2.3

11 files

1.2.2

11 files

1.2.1

11 files

1.2.0

11 files

1.1.0

11 files

1.0.10

11 files

1.0.9

10 files

1.0.8

10 files

1.0.7

10 files

1.0.6

10 files

1.0.5

10 files

1.0.4

24 files

1.0.3

24 files

1.0.2

24 files

1.0.1

24 files

1.0.0

9 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page