Skip to main content

Matlab grammar for tree-sitter

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.2.tar.gz (76.3 kB view details)

Uploaded Source

Built Distributions

tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-win_amd64.whl (51.5 kB view details)

Uploaded PyPy Windows x86-64

tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (53.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl (50.3 kB view details)

Uploaded PyPy macOS 11.0+ ARM64

tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl (49.1 kB view details)

Uploaded PyPy macOS 10.15+ x86-64

tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-win_amd64.whl (51.5 kB view details)

Uploaded PyPy Windows x86-64

tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (53.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl (50.3 kB view details)

Uploaded PyPy macOS 11.0+ ARM64

tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_10_15_x86_64.whl (49.1 kB view details)

Uploaded PyPy macOS 10.15+ x86-64

tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-win_amd64.whl (51.5 kB view details)

Uploaded PyPy Windows x86-64

tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (53.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_11_0_arm64.whl (50.3 kB view details)

Uploaded PyPy macOS 11.0+ ARM64

tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (49.0 kB view details)

Uploaded PyPy macOS 10.9+ x86-64

tree_sitter_matlab-1.0.2-cp38-abi3-win_amd64.whl (51.4 kB view details)

Uploaded CPython 3.8+ Windows x86-64

tree_sitter_matlab-1.0.2-cp38-abi3-win32.whl (50.7 kB view details)

Uploaded CPython 3.8+ Windows x86

tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_x86_64.whl (76.6 kB view details)

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

tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_i686.whl (77.0 kB view details)

Uploaded CPython 3.8+ musllinux: musl 1.2+ i686

tree_sitter_matlab-1.0.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (79.8 kB view details)

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

tree_sitter_matlab-1.0.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (79.1 kB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

tree_sitter_matlab-1.0.2-cp38-abi3-macosx_11_0_arm64.whl (51.2 kB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

tree_sitter_matlab-1.0.2-cp38-abi3-macosx_10_9_x86_64.whl (49.8 kB view details)

Uploaded CPython 3.8+ macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tree_sitter_matlab-1.0.2.tar.gz
  • Upload date:
  • Size: 76.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for tree_sitter_matlab-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0eb7ca5f992ec919f495be96d48da00bd05e34644a4a860223055eeb4b1bc8b3
MD5 ae287a43364aabe51f37b20b7c971705
BLAKE2b-256 85ffddfe31049bb7965e1f06db5545762306cd7660b7fcdce3f77c3933d01e72

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c20f2936ad6cb9964aa2978623c6879abfe81a82497dca617397a9de1bcd2316
MD5 b2b06cca4aec710a5e9c1f0f42b149d4
BLAKE2b-256 7ca388a030d111f02e37ab0609c89b514b3d0a05fd785bbee282a0e0325a7e68

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-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.2-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f33470a4b676fe4672f314e26b5fd1e505cd5a6a1146853bfd9532f3f29766e
MD5 8ca3fbeb05ba473d84c746a6616c88ef
BLAKE2b-256 452b79b13fe5d078456c415e2f3bccbb5278c279a0d3a55ada8817671d963acb

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9673405c04b357070d459597bfaa8d1190b8f1e610521b3753bb45ad20e787bf
MD5 ff5b5b8c0a884856555bc9913d63f812
BLAKE2b-256 22a78de5b7701e94d7b23cb1fa046ba80bf33cd26fa963eb8ba32f6186018a00

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3bee5cdfa2f7b5d066de5466b0fb980a5226ab8509e312647b5732fca4450007
MD5 f7b8e60968d4450009f1922a61dc1a8a
BLAKE2b-256 d44d6a083c5fc14ff9311439d2f78cd550d3301a5759a3c926e2bddbf8e6d6ec

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e07074f9d300ff2cb3e4475c24cfa1aeec3025df6a5269fb082e2b2c14e06c2c
MD5 5fef73b7b11af050afde119562653cf3
BLAKE2b-256 a000cbb90fffe3db0bb520782bd89cfb515cacb03600f14a8a596bf2f856c033

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 77ab742eb1f7934479f98eb0e4cdc71a6468c4c503ab495c4b3477ddcb7f5373
MD5 43d2f0b04e05958a00bef36de3c091f6
BLAKE2b-256 f5b09497d1add025dbcf04e93fea9ce286dbeb130b9ec8fe6ad2c399f103cde5

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-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.2-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f36cc33b868c369d767a6ebaa2b56e75e72198919e34dc1a16f23315c8132620
MD5 bfe4ee032a737c467844a3f7be2a4e5a
BLAKE2b-256 5a50842593e3f5b75b216d0c8d0fff7e0d0ee4a1ab0a99af26cc4600e0244637

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ac68547a701fc428f80e8c662ed3fdab223cad3da1f02336ed6e2ef00181233d
MD5 4146097f2cbe015eba84eb290d6266b4
BLAKE2b-256 c0410a11c837153473799fed52debc06734be40a36bccb5201a70974b9e7f562

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b7fd4adeff66fe6386e2eb135e3dab502fc98ff65ea88f95018ef38966aee03
MD5 bbb60f72853336bf4e6e49b9cdf250fe
BLAKE2b-256 b32463629710ba60f48a76e85aab561c8b4575b264f9168978ebe91eb3ee90c6

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp39-pypy39_pp73-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c0c79f5e10a2e43e93f2717eb20fb42e7f88c69abcbed5d509c8364989bfcc6a
MD5 1907b7731da412edbb9272dc98a8d7e4
BLAKE2b-256 7455cbed81b6d09d0a6c52c59acdcb9a5fc994e56f174637f1cc1991bcd6c6d2

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a3aee1a3d62f3880f00431102eb30e40077a6d3ee72c300cfe977e82d1cccbc9
MD5 2f065368256e515d788e71ccee28631c
BLAKE2b-256 74783746a013aa343b39a4cc4d7ae5071ba3ee22c74c33a341eaf5366bf717ba

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-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.2-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e3824f9c9eb12bd7415a28a41fd098ddb10ec742c2ca0ab3432c749b9ff1460
MD5 36bea5b115f4368100eb6eff0aa18fe1
BLAKE2b-256 175fa1c9bac0288dc5cb00c24b9c3929947dca14adf080c2f91e45192d3bf20a

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e63f534250ebecbc5812b129edbc4614e4056c22965227029b2e7fc7d7a4324c
MD5 a1bb549802e96b5af96966754cdf665c
BLAKE2b-256 aa54773781a4dd65e5f3384bed54da515fcf7e44db3cd48962448a964048051f

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70931a1d18b123c334cb8468d0c85eae2d092bbeee6c743b9b737604f4ea5c03
MD5 c3e687c30ef7a8df3630da569cbd1ba5
BLAKE2b-256 d44169ee6d8aafcea187b137966b4e33954bf02edebd8aa98e266684b8a5839b

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5df28c864dca7f1c1abc407577f7204d5905f15f54c4c31f38d7083d94858976
MD5 439d56fc414402cf1138dcac2fd2bc6d
BLAKE2b-256 8d81cc437b4e40c11c5d3961b890e3650584f4b8b6e5dd8661ce271cbe639908

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3052aa69e969c44d06303c8432beabef6de1805cafd02c4ae8c54e0c8cc8373f
MD5 1c376321aae114db5982241e40e1876c
BLAKE2b-256 cd7bfafee43fb78a97e03bfbdc111c6ef14c89fdfe93f78a860945731c620002

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 90eeed2de47ff14d660aab49f49d823cb975b5b60c3169cee909a2b8536b126b
MD5 6b675f015ed6e1740ea2b1691c831f6d
BLAKE2b-256 7220af1586f399cf50a4706d3900959bda9a738406a573bffe45bc3731203a53

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f16d89f22c2745dc3c7a1d24cd5be4b3ba680ed30c843d3f54656522e1e77468
MD5 65d6ac3972606a42d95cd54ff6c7f554
BLAKE2b-256 27d4ea3f914138096b981f187144d90ba54cd7749167b605bd1539026ce9d429

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e52a4c72de5b44de0a2d28909509b2a46e2d16067b70702476392660a3b60ef4
MD5 4381cc8d049216291a138323f1567e6d
BLAKE2b-256 2d9f4ae7198c89979f63117282b8d67189b243a13d72b34d5b3ba4152b9454b6

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-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.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 819374e183af019c2cf0d4ecabd05a0ac0546d92bfcac285f4d72c857962716f
MD5 c0e1930145758275c9c53fc09bb42b10
BLAKE2b-256 74ddf527d867cd9e07380fa2be4ee4c7ed13c71faf4ff30ef3c4db85ed38d269

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-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.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2e5d27126f232883fcbcb5283b1732049695fc511098fbd65244466f11484181
MD5 95f96ce46824b029d996fe50911f9418
BLAKE2b-256 8e90714f139a69b3078b781695a2c449796276b68ed1108b67cdc5d2d682e8fe

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e0d08c0ba460ea57c6fb73750cd87f09af5c240a2c4f165d1629d761d550b2ed
MD5 e8b8ba24bbab76c6f998792f14d3af2d
BLAKE2b-256 86b2c29546c88068c7c4c5e8a5eb16efac3c89b808c259fe5513989d09631792

See more details on using hashes here.

File details

Details for the file tree_sitter_matlab-1.0.2-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_matlab-1.0.2-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6d6346a4e9c9d67eb2dc45e02d74abf8ca91cfbe4634bc5f2ba4ebb1ea4dc5e2
MD5 f18f0d2f2ec3227406903288d563f46a
BLAKE2b-256 c9fa25098950b50fe04774e0f8b58c4d77d6e3aa21c8f1731fb8141ec4185043

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page