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.
  • 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.2.8.tar.gz (159.4 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.8-cp310-abi3-win_arm64.whl (76.2 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_matlab-1.2.8-cp310-abi3-win_amd64.whl (77.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.2.8-cp310-abi3-win32.whl (76.6 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_x86_64.whl (108.0 kB view details)

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

tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_i686.whl (110.2 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_aarch64.whl (111.6 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.8-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (113.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tree_sitter_matlab-1.2.8-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (110.8 kB view details)

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

tree_sitter_matlab-1.2.8-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (112.1 kB view details)

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

tree_sitter_matlab-1.2.8-cp310-abi3-macosx_11_0_arm64.whl (81.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.2.8.tar.gz
  • Upload date:
  • Size: 159.4 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.8.tar.gz
Algorithm Hash digest
SHA256 aaa1edbe4ca45a24e5053d66673ef40a15a6cff3c8c93362e9914b6d166afd35
MD5 b0f389a1bcfc36e4a9fd576a64c3f37e
BLAKE2b-256 ff38a95235f3f0601f61058f85c6ea241a699a26a9b610dcb59420bdde09c7aa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 a62c152013ada742ab06af6d9ce05663dfa5701be62aa95f093db8c481096c61
MD5 a4e929e526bb840bb9e3f0923ef27c7a
BLAKE2b-256 29e9b4eb2f8669476d9a85b69b2d9801d96d10a578a424fad65797fb14cd8910

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.8-cp310-abi3-win_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.

File details

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 55a3c2cc5eba8a843389cc832fd1641548e04a0fa138bc157afddfbebeec2c67
MD5 b94ad9873fb89da7739dcc86a4f3bf99
BLAKE2b-256 d229dc1cd1d30a0725e44795dadfcdab650afe96628f9c1642678cf9356d2395

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 37ca7031b8d72dd47d8257593748f1a10ab2e7dd8813894e3c62c8fc2b6f5312
MD5 ddc2b74582836e044b5043e27d81bf0f
BLAKE2b-256 f0205dd73a9ef705314770ff8b9cdfbd7ead569fadb762f44e161f8eca8dea32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3bd76c65eddb244d8e796d07c0693500bdddbc116aab3ddeb137268f1c672d5b
MD5 4f3c51a17fb0a5cf751acb5f08a94158
BLAKE2b-256 86efb4eb817c5d63e0a182bb1107a8bc83b67124e7ec7edbb0c45429e1a76356

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.8-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.2.8-cp310-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 672a6f0b819abee5683101754d841c614fa0e7da3dff28b1829c459cb843b949
MD5 2a47f2f093589c8af7e13839ce7867c6
BLAKE2b-256 32c26764ad7f5149178aa9524796f3da23ffb2430de804d104b2761f638cfcba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 31cb9949961428825cba4eaf76bfa80513071e961ecad3d016beb6d2ffc56aff
MD5 8342fbd48be8a91cb7dd0ce8709d8ae1
BLAKE2b-256 17728083d275cb51c19e19c000d239aa52881c0a4ad3c6900309f7fd1e146795

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 007a8a481ae168a107b9403e905b47c8d1b5815dd18a633213c313fdf46f8ba6
MD5 91055763c35b627ce576bd49fd937759
BLAKE2b-256 313fe8e1d54acdc847381733a0b3340c80985c9020bf969d16dfd816373f1b76

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.8-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.2.8-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.2.8-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 83d0b139b9781a433ff280c8015ee38799dc5cc10f1ea1cc984d670ec6be213c
MD5 dcdbec640d4f4dd4d53f03b8afa8e522
BLAKE2b-256 f8d75a70bd730ed5049814bd11812db592746fdeb3c8e009f608496747cdcdf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.8-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.2.8-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.2.8-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 216675771ad1baefbf52d8337aa618a5dfec541a135f60035a7f051aac4c491b
MD5 fbb2811c280fee9c161595c24a89e6d5
BLAKE2b-256 e88ea0a3f3baea88389f8f183d4a006e1420bad51b9316c8895769c0830cb861

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.8-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c605dec7c8674605f83648d40158468da3cf698f024456ff243b47f68e8f2fa5
MD5 97c6b9a4538db43cb2d1a60361308fb3
BLAKE2b-256 a8c6fb02c8c63d7624f200e198a9ecf21a7d93f229850f25882afbc58d6f258e

See more details on using hashes here.

Provenance

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