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 now the default for the following editors:

  • Emacs: Through the tree-sitter-langs package.
  • Helix: Builtin, now in master and will be available in the next release (whatever comes after 23.05).
  • Neovim: Through the nvim-treesitter plugin.

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.0.6.tar.gz (86.5 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.0.6-cp310-abi3-win_amd64.whl (52.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.0.6-cp310-abi3-win32.whl (51.5 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_x86_64.whl (78.0 kB view details)

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

tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_i686.whl (78.4 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_aarch64.whl (80.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (81.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (81.3 kB view details)

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

tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (80.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

tree_sitter_matlab-1.0.6-cp310-abi3-macosx_11_0_arm64.whl (52.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for tree_sitter_matlab-1.0.6.tar.gz
Algorithm Hash digest
SHA256 c144bac4d6a454cc9df870c894bef244bb0e71b4392e8aeba1e16a123b9625b5
MD5 745f2e15f9b6c10f0306204473cf466f
BLAKE2b-256 1a1129c5bbe86707407839775aeae94e7e4e03768ba7e16a18c8ae255620e5e0

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0c74c90666d295c7f27dc875d44c7c8dfce3e254c9221aafb105b9884a966d87
MD5 1abf87f0b9ef91f3a78c5f4c02c42e3e
BLAKE2b-256 3805a0a77a78da1b8c2465c7d4caf8e215e80edc92499e6f2d1ba01ad5918b22

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 f42c06892eb84f083f1a95f0526fd1d0310990c5d9f277bd47e312f5b1fd6146
MD5 3c883e3bb7a2ea65c2b7cff3c30527d1
BLAKE2b-256 ce37ea00565165c953a98568e2cc8d97207ac1af2334360e0d484a64f638b63f

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f5d5b12d44fff6e23c0e87ba106df2624b01b3a3a0e247442b56996fc3c0807a
MD5 2bb751bdabd31f2bbd8110f49c4a078e
BLAKE2b-256 008f69688e0feac9567498457de67f81cb3acab13ed5aa365a744f7041b7f3f9

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 cd201dc7d48fc18905ff78b0dc78d75505f306f71a8285a1f2db06353a0b696f
MD5 7847803804d9a6ca2feb71b32b282822
BLAKE2b-256 554e35d5714024d3c8536ced1d066159ea30cfeab65a1b06380de1fc52776992

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_i686.whl:

Publisher: wheels.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.0.6-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 31effd54aed1c5ad94c63eeba607c1b5b33809f318ebfa73a3a485b1470572b6
MD5 35f9fa9361843d985323a5be46dfa897
BLAKE2b-256 fafbba9214ed7926986fe6f17c21b4555440240549f5a348d05aa98b313f4804

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6b9fba537b6eca78924bca75b66d8a0a181df8412224eb414eb429f3c8343caa
MD5 b0d6762f37f5ae5dd3523b66d381afbf
BLAKE2b-256 6bbeade0ef78ce82e93467448dc187a9a50e395ea37a224d8f03f3345df89e01

See more details on using hashes here.

Provenance

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

Publisher: wheels.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.0.6-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ba0bb06f935148c855a46edd385dfc5760f697e66b433c2880119a38b816985
MD5 dcc6f26306ad25cb51c8837eaeb6b7ed
BLAKE2b-256 bb322671f69935824a71b47aff00e81b96817989d815dc610edb5fbf35763d79

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.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.0.6-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a0e4442777948a0d305c0fab76a9e55c9e7f428402f75d62a98fb00106171eaf
MD5 4ca9472133ad0c6e5102431cb3358322
BLAKE2b-256 08d209c46b24df3a516dd179e2b27c5836c02d68dbdc3df1732c8da45a4c71f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.0.6-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: wheels.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.0.6-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.6-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 75bd3afe542309213265498f3339df486a633f47bee3f2e0fd2b4f366e240817
MD5 009c9cfca0b8ad6c496a09c32711b66c
BLAKE2b-256 062fd3723bb488f5dd48670b59d6fe3ebcbce1bdc77895c3b186e98f0684b131

See more details on using hashes here.

Provenance

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

Publisher: wheels.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