Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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
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.
This parser is now the default for the following editors:
tree-sitter-langs
package.nvim-treesitter
plugin.
FAQs
Matlab grammar for tree-sitter
We found that tree-sitter-matlab demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.