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.

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

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.12.tar.gz (168.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.12-cp314-cp314t-win_arm64.whl (83.0 kB view details)

Uploaded CPython 3.14tWindows ARM64

tree_sitter_matlab-1.2.12-cp314-cp314t-win_amd64.whl (84.4 kB view details)

Uploaded CPython 3.14tWindows x86-64

tree_sitter_matlab-1.2.12-cp314-cp314t-win32.whl (83.5 kB view details)

Uploaded CPython 3.14tWindows x86

tree_sitter_matlab-1.2.12-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.2.12-cp314-cp314t-musllinux_1_2_aarch64.whl (123.6 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.12-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (126.0 kB view details)

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

tree_sitter_matlab-1.2.12-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (119.3 kB view details)

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

tree_sitter_matlab-1.2.12-cp314-cp314t-macosx_11_0_arm64.whl (86.4 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

tree_sitter_matlab-1.2.12-cp310-abi3-win_arm64.whl (80.6 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_matlab-1.2.12-cp310-abi3-win_amd64.whl (82.3 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_matlab-1.2.12-cp310-abi3-win32.whl (81.0 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_matlab-1.2.12-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.2.12-cp310-abi3-musllinux_1_2_aarch64.whl (120.9 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_matlab-1.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (123.4 kB view details)

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

tree_sitter_matlab-1.2.12-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (116.5 kB view details)

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

tree_sitter_matlab-1.2.12-cp310-abi3-macosx_11_0_arm64.whl (86.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.2.12.tar.gz
  • Upload date:
  • Size: 168.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.12.tar.gz
Algorithm Hash digest
SHA256 e6f8786e17da12af0bb7a31733f066faf24d21ebf1616d586af16ef4deef8899
MD5 e407f60a61297e74127354c0b7d34d4d
BLAKE2b-256 c72c88967e021f6f55e42d32bbec2ca2aebe4b9c8ef459f4d52cf8ac4b125c61

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 922b0cc1b89215256d278b288c5861981368cc48e6c5cd28a9d6a5f2aab92c69
MD5 6c387b8166469204ff4cf87b248b91b4
BLAKE2b-256 413bf79d49fb724238a14baa795e5108ba13c3146432fe61c155f690c821c9b6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 ce7548812525abb7cff10a8fb9f3b5411799c53275b6778b2be3288e3e456fbb
MD5 2619674e787078ecbd842e690f1fc003
BLAKE2b-256 c60cc0cc05cdde9daef6d21c014dc86fc01eb5b034ada7ca029bbe9cfdd85145

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 8e5d35250f954dd6d44c64ea133898771559baa0e7db6e3d97539fcabc019676
MD5 ff81da003046f3fc341b69feb4787d9b
BLAKE2b-256 b170aa2c185210dda55f69bf7a945e20f83feb1ccf2ce9e61be419261897f9f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 44868f2e1ac3bbc202a7f6d2efaa72fbabafddb27858f95b22baec3995ca6786
MD5 66ddf97910308dfc377c5a39fdfab0dc
BLAKE2b-256 2b73922a5aadecc9e5d05a831ed4fcf3f46f8c9ab8186f501a69806e57cc48b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a2b5f46834b5871b705ef49f0140f00c46ed0cc7cdb80741a2a49d1dbc337e9d
MD5 592eba16d3b28726246ee841ee505f28
BLAKE2b-256 496283d5627f2ecb8ffaf3debc74e87d7d4c10c658c84b6607b1f472e499765d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 90ea4bb29207d821aee4b5c7b9f271465f65de1c16a35b7431f709abc372ca9e
MD5 0ab057ce382043ae03e714931ebb43b1
BLAKE2b-256 275701491748293f2f00fbb12a5dfe2b9a3f2dc6d906205df0af1b40783b9766

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.12-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.2.12-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.2.12-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3f352f67e5e84b5e606f211c1cdebac649022730679dfd719782960ca5f24bbb
MD5 eed5661f7b9a98cc5315c5283ab0e9e7
BLAKE2b-256 3bb4f1fb0b2e555c6d263b5e93c2ee0906c777ad499fb247d54df1123ef5a4e6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df95f08fdaa07b7d95df200b88199d600cb88b3fd98b204a864f8c892bd6a253
MD5 d3a3c60791d77b4aa6e28a3b19f3cbe0
BLAKE2b-256 a038ce808f9497a55cc947be9c2187acbd0a187e3163153a9764c2a2ba1410e7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 ba375dc65fdd07baa8f8b354a9fbe714952ad1dd8a641ffaf2add1e8ca6263f7
MD5 7b699ea3e3b5dbf161c355e7bb4caab8
BLAKE2b-256 e5621940b2f1fe1f312210531a372a0aa61050a3ee434b4557adc2347182a9a8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d819873a3d7f95f73e8e33ee87351f4cd06b80326ca05b034f4ddd8a1866fdf7
MD5 0423069c6da023c2dfd15ee234721620
BLAKE2b-256 fc5fd31f8b14f2b47c416cc4c90913a54554b43f904d5d759fb2e53cde7f1874

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 a89f7e32cf8971bf8b36e1c8813f531aab3653dd62e1d50533d7d10fe357b5fc
MD5 85497fcd2997286ab1791827d6965155
BLAKE2b-256 ca8aeff4e2b11059a5c931867802efd9ff296a96c484aed18b904f5baa6bade2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 208eea24e1d205526f9ee04d8011b23a8cd23a43bf72852a2a2d4053958988f9
MD5 82c8767b7f4a346418c223c410a2ac0f
BLAKE2b-256 331a3b97b84f6a04b3baf9adf2a64eb36fadaa8983e34bd7edfc957eadfc2965

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 04ee9cd6afd7756b7b2228887ed4c62ced0e347aaf7519f52f1eeefc04386cd0
MD5 3c104d484c867c9e06615e07b209894a
BLAKE2b-256 e165a8afcd2040f7f6e48b69227cf1135aea6002b3d8350409a69715a9ad647f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f2bf41451319f35394483107ebe8c4e929623e02ab1bb7bfaf306d54d95a3921
MD5 636bd522994a1b8fb9fddee9b465c652
BLAKE2b-256 f7ac9e347de93bb143967157edbb4b6f3fce01502c0197a9f397d54439a62636

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_matlab-1.2.12-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.2.12-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.2.12-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 99e69ebc2fba7f724ebb880d4c52753316a1df8336432773e633ca4058b15ac7
MD5 d6a906253dd5ab147c93a882cc6b3c32
BLAKE2b-256 b54b4e8e6f9df46c7acba8f302ba61281bd0cff038b8c8f560c66f73f9115f49

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_matlab-1.2.12-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8977509532a21818aa0113d8b44e584b5d92ded633c60fbfae8c791cab84cf69
MD5 a3b478b92d4b12793fdecc2989be5e8a
BLAKE2b-256 1551738e7aadc00f63a055287fe0600be70e73dc6caef457a33d92415b376793

See more details on using hashes here.

Provenance

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

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