
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
tree-sitter-netlinx
Advanced tools
NetLinx grammar for tree-sitter.
band, bor, bxor, bnot, lshift, rshift)and, or, xor, not)0:first_local_port+1:1, dvPort.NUMBER:dvPort.PORT:dvPort.SYSTEM)__file__, __line__, __date__, __time__, etc)day, date, ldate, time, etc)true, false, etc)NetLinx.axi)NetLinx.axi)ON, OFF, TO, MIN_TO, PULSE, etc)DEFINE_CALL functions)'')/* */)(* *))The NetLinx language allows preprocessor directives to be used within expressions, like:
(foo #IF_DEFINED BAR && baz #END_IF && foobar)
While this is valid NetLinx code that compiles correctly, tree-sitter has limitations when parsing these constructs due to the nature of preprocessor directives operating at a different level than normal syntax.
When encountering preprocessor directives within expressions, the parser will:
Example Parse Tree
(source_file
(expression_statement
(parenthesized_expression
(ERROR
(identifier) // <- foo
(preproc_if_defined_keyword))
(binary_expression
left: (binary_expression
left: (identifier) // <- BAR
right: (identifier)) // <- baz
(ERROR
(preproc_end_if_keyword))
right: (identifier))))) // <- foobar
Implications
#IF_DEFINED BAR
(foo && baz && foobar)
#ELSE
(foo && foobar)
#END_IF
For JavaScript/Node.js projects:
npm install tree-sitter-netlinx
# or
yarn add tree-sitter-netlinx
# or
pnpm add tree-sitter-netlinx
For Rust projects:
cargo add tree-sitter-netlinx
For Python projects:
pip install tree-sitter-netlinx
For Nix, NixOS and Home Manager reference:
pkgs.tree-sitter.withPlugins (plugins: with plugins; [
tree-sitter-netlinx
# ...
])
If you want to install the grammar manually, you can clone the repository and build it yourself:
git clone https://github.com/Norgate-AV/tree-sitter-netlinx
cd tree-sitter-netlinx
npm install
npx tree-sitter generate
The grammar is designed to be as accurate as possible, while also being as flexible as possible.
The grammar is intentionally permissive, allowing it to parse syntactically valid but semantically questionable code. This approach enables:
As a parsing tool, tree-sitter focuses on syntactic structure rather than semantic validity:
The parser will accept patterns that the NetLinx compiler might reject:
The parser deliberately prioritizes syntactic flexibility over strict semantic validation:
Section-Independent Parsing: Declarations can appear anywhere in the code, even outside their semantically correct sections. The parser doesn't enforce section-specific constraints that the NetLinx compiler would apply.
Context-Free Analysis: Device definitions, constants, and variables are parsed based on their syntactic structure rather than their semantic context. For example, device definitions in a DEFINE_DEVICE section are parsed as standard assignment expressions.
Support for Implicit Typing: The parser accommodates NetLinx's implicit typing behaviors. In NetLinx, when type declarations are omitted, the compiler applies implicit types—INTEGER for regular variables and CHAR for array variables.
Examples:
DEFINE_CONSTANT
FOO = 1 // Parsed as an assignment expression rather than a specialized constant declaration
DEFINE_VARIABLE
bar = 1 // Parsed as an assignment expression
// NetLinx compiler would implicitly type this as INTEGER
baz[10] // Parsed as an identifier with subscript
// NetLinx compiler would implicitly type this as CHAR array
This approach enables more resilient parsing during code editing and provides better syntax highlighting and tooling support, even for incomplete or semantically imperfect code. Semantic validation is intentionally left to the NetLinx compiler or separate analysis tools.
This project is maintained by the following person(s) and a bunch of awesome contributors.
Damien Butt |
Thanks go to these awesome people (emoji key):
~kb 📖 🐛 💻 ⚠️ |
This project follows the all-contributors specification.
Contributions are welcome! Please fork and open a pull request if you have any suggestions or improvements.
Any help would be greatly appreciated.
FAQs
NetLinx grammar for tree-sitter
We found that tree-sitter-netlinx 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.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.