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.10.tar.gz (168.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.10-cp310-abi3-win_arm64.whl (80.3 kB view details)

Uploaded CPython 3.10+Windows ARM64

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

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.2.10-cp310-abi3-win32.whl (80.9 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_x86_64.whl (114.7 kB view details)

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

tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_i686.whl (116.8 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_aarch64.whl (118.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (120.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tree_sitter_matlab-1.2.10-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117.7 kB view details)

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

tree_sitter_matlab-1.2.10-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (118.9 kB view details)

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

tree_sitter_matlab-1.2.10-cp310-abi3-macosx_11_0_arm64.whl (85.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.2.10.tar.gz
  • Upload date:
  • Size: 168.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.10.tar.gz
Algorithm Hash digest
SHA256 85c2cc05d4f413f332ef156c6cc2e4106f18e63944fd41c957e58c19d3680404
MD5 e87238886c0bd8654826098e782384b8
BLAKE2b-256 f090c00e6ef1849f336d164a6b3d722e734a4c1c5f9f7f777ff6f4f69f20639c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 43b9a4480a274b195d7731a803b28bf85b8df308264a460a92359667d61a8de1
MD5 b93f786a36a0f49aa725c4ee69aa4ed1
BLAKE2b-256 7a21b3807616ab6ac16a7bbe34316db19c74ad4b4f6259e25f22247c464c280e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d056d4bee9220c1eecf40a4d47577a08d43697a935e9b98908a62fd1ea678983
MD5 0a24ae933df15f7ec9920aa50e277c48
BLAKE2b-256 7abe98baf333548d32967bc452085265943f2fbc8d70ad92205bd1092a115138

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 f82d0a2935881aacda37247fe3afa62865671e08cb4cc4bc844f07ed075c71c4
MD5 fb75c2a85f9cb11ca7d80014d719443d
BLAKE2b-256 331343dc19c8c23c81abbaa61b1577132653b5183e499b9304aa8e7da8a07839

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0411efeecee1fbc619df8865d14b9e53b7c3504af18d8cf7d8abec628b9c209c
MD5 7c2d2cb13bfcb8fb8d6d1ea5286fdf0b
BLAKE2b-256 27e4464c90322a4a92810b5a109b5de2db4c0c996fd18f66173e193d5f5ce702

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 d72eb621e909fd46077676295ab89b3c3dfb7e3a4f59127c13df03a8c82d8345
MD5 8183d67c51d475099ba4defdd3ddfb68
BLAKE2b-256 20f2f5e3b43e9753270c39ae5bb60a9c662ba80a4f58ea22965928abde254f24

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 3c1ed15445e6fe2429bced69310bad6e8f5cd932b4c5c36ff39f53e82cfa92f3
MD5 f6c36bfe2eea800ffb0510a0479a5a2d
BLAKE2b-256 2e869f593cbe26cfec2eaf69978219c787ee6d07eca698205f63835ff2d41706

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 43d724dbfa697e558cecf46445a413a2e821246187e112f0eacd27fee1d1381e
MD5 8f849102f56f41721574c00c2dcf05bd
BLAKE2b-256 265653d2292bc98d58ccb0b0ff3d17b3dfe7977b09f2fdb9bd89e3f03cf0a723

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.10-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.10-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.10-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a4b10892e88ec53e50bf42b84337a934802031455c6a8ff2cdce3bfdce80681
MD5 491ffc2c74d12fd873ef124100b122d4
BLAKE2b-256 03191e201e0bd8e987007e51a49f9aa649c7f66cdd251d1b44aacc2c4e51540c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.10-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.10-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.10-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 dd3d9b551c084187741e3994ea28ac0421bd92f17075e4e2c310eb0096e7618e
MD5 3f82564808121948d64569b014364c5c
BLAKE2b-256 66a8cf1e3331c624f3bd5afc651a359512af72ebc7654c41a8a954b2f4a72dc7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.10-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cffcb768782e62a62ec361c6f64a45930e0a0cac6516295ef4c1ec21efad5039
MD5 ae0c977002ec2d5b4b9e0715bb1a1f62
BLAKE2b-256 ae997c598113abdc9fd64e4bb6e7d4ee76c3f710706871f4d19acbaf013bdafe

See more details on using hashes here.

Provenance

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