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.9.tar.gz (162.3 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.9-cp310-abi3-win_arm64.whl (77.7 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_matlab-1.2.9-cp310-abi3-win_amd64.whl (79.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.2.9-cp310-abi3-win32.whl (78.5 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_x86_64.whl (110.8 kB view details)

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

tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_i686.whl (113.1 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_aarch64.whl (114.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.9-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (116.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tree_sitter_matlab-1.2.9-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (113.9 kB view details)

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

tree_sitter_matlab-1.2.9-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (114.7 kB view details)

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

tree_sitter_matlab-1.2.9-cp310-abi3-macosx_11_0_arm64.whl (82.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.2.9.tar.gz
  • Upload date:
  • Size: 162.3 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.9.tar.gz
Algorithm Hash digest
SHA256 420aa6a8b56b865ee3317be4df7c554efd9884557d19aa14bc4bbebc6a596bc0
MD5 f60994e0f874ba256307b53010ece51c
BLAKE2b-256 18e117e45f4e46bbffbd5df0c6960d4d3d6431e363d785bfb578d8c057b0751b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 88f06f68af75332d33d7d3d89b49e7b2f75727020088423501b895c42c9000f4
MD5 a797da2182a0befa412b38cfa59d7b88
BLAKE2b-256 737e2ee0e2a6537e6dd98a03745d792a0af4a8474ddfd0fc7a28188998814d07

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7266eb2cfb0ad130f01a9ea10d77071f21f3098bb7537a4d894226d2cd03cbc5
MD5 51f322032c3cdb38b407aa528977b509
BLAKE2b-256 a509e1c2a30968b509c6e9b8650806ea410cda5dada2b9fede78248cc92d860c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 22740ede6e3c29e3d72626556c9467ab9244ed70b67eb59367a32acf902c8765
MD5 a1ef1f0c064cbbbcb1385f084d7486b4
BLAKE2b-256 126278e8ae7cea42a099f481a8d35db53444d6c18e94e9eb0ce0b8fca46323ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ec01581a415eb6c5ad66b32c0a7ba4c2da3a75cab3da836dda9b1ac1a76cff4c
MD5 db6be4134cd45275007a160c3c7f2154
BLAKE2b-256 0dfdb4d6eea595d3a3b3f68a0f201e1731d0e4c4ab0de0520b6a6c2103c64e39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c05551ee3f86198763421e846098333088bd0c48bb64543c4283d39c04e176d4
MD5 27ca561eeac9cbdd9246117c2e89406b
BLAKE2b-256 2902c5909cd1f6f272b8a2a75873352711346ee39576cd0574ba24c8a4cbaf4a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 52b3f24097499b08dd2ef88f636e3676443f55fd1a93657dca881303d0479084
MD5 6f40b74add1c5e5fa04a0ed4a2b15442
BLAKE2b-256 494198101ce0626bd711b43383748e8806a896b198c1892efc8a6e25f499d7d9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c7140286f932aa3b3eff238c98ceb7d286d155174afc84afbf79a7fdd6c448b1
MD5 c2000fa68753b5919c85b812a7362194
BLAKE2b-256 710808390c81667f61bc06abf9ea1632bb5297c5e81300d9e2cbb7eb7a55b9cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.9-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.9-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.9-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d597c46e5166de5e5f487310237dfad9711888e038354a2044ab36b1392d5522
MD5 6dd3e656b3a6c34fb24082f9895395fb
BLAKE2b-256 277dde325e83390a4fe2e2291e3c273f44934bb40986500cb8ec3aa76e6aeb89

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.9-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.9-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.9-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9b011850d5f09e49099f58dcdfddb7059c6cd369f0d8068a1e6a6f8c0c5ee8c0
MD5 384707a3edd8c8c7ba5963c97646a15e
BLAKE2b-256 e465f6b6da51732f1da1f1b51361f8e05ec24bb75c8d7ad589e205a1938bbe5b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.9-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3824699fc8d2b832e301e45137c0502b30b41271565bb370606a6e1f7c34104f
MD5 598f052d9bcaeadac6dfdfc5c2cb065b
BLAKE2b-256 3729b7e2aafc1b14dcf8f6d9652fb20652206d766a38a34e1f9328c247110637

See more details on using hashes here.

Provenance

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