Questions tagged [treesitter]

Tree-sitter is a parser generator tool and an incremental parsing library. Use this tag for questions about how to write or compile grammars and how to use Tree-sitter's API.

81 questions
1
vote
1 answer

Resolving fully qualified class names when parsing Java source code

I am trying to parse Java code using a library (preferably python) so that I can parse arbitrary Java files. My goal is to find out for different test classes which code they depend on (which code is being tested). This will be used to train a…
Nick1503
  • 11
  • 2
1
vote
1 answer

How to configure NeoVim Treesitter in VimScript?

I'm trying to configure treesitter syntax highlighting for my neovim config but the docs only show examples with Lua and i am using Vimscript. If you're using VimScript they redirect you to an example of calling a Lua function within VimScript but I…
1
vote
0 answers

Is it possible to use vscode syntax highlighter to a ast file using tree-sitter?

I am trying to get AST file using vs code syntax highlighter file for a custom language. Please help me
Raghu
  • 51
  • 1
1
vote
1 answer

Parse C source code and extract variables and methods from it

I want to parse c source code for extracting variables and functions from it. Is there any library available for this purpose? I tried to achieve it through query language available in tree-sitter parser generator but when I run the program it says…
Ansa
  • 11
  • 2
1
vote
0 answers

Using a tree-sitter parse tree for inferring types and auto-completion in language server

I am attempting to make a language server for a small domain-specific language, and I was thinking of using tree-sitter to generate a parse tree to use for auto-completions based on looking at type annotations in tree nodes. The language is strongly…
et97
  • 75
  • 1
  • 6
1
vote
0 answers

How to properly parse a multi-character token in tree-sitter scanner function

Tree-sitter allows you to use an external scanner for those tokens that are tricky to parse or that depend on specific states like multiline strings. The scanner takes a convenient lexer object with several methods that allow you to "scan" the…
Danielo515
  • 5,996
  • 4
  • 32
  • 66
1
vote
1 answer

Treesitter precedence not taking effect

I'm learning how to use tree sitter and making a grammar for parsing simple predicate logic. I'll clearly need precedence to make negation, ~, bind more tightly than conjunction and dis-junction, (/\ and \/). I think I've applied precedence…
asm
  • 8,758
  • 3
  • 27
  • 48
1
vote
1 answer

How do I get the value of @punctuation.delimiter?

I want to get information about the tree sitter. Among them, I want to get the value of @punctuation.delimiter. How can I get…
1
vote
1 answer

Module compiled against a different NODE_MODULE_VERSION when developing an extension for vscode

I'm trying to use node's tree-sitter package in my vscode extension, but I get the following error: Activating extension 'extension name' failed: The module '.../node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node' was compiled…
1
vote
0 answers

nvim-treesitter: query for jsdoc description within javascript file

I'm experimenting with a testing regime for my neovim plugin regexplainer. The idea is to put a JSDoc docblock containing the expected output on top of each query. /** * @group CaptureGroups * **0-9** (_>= 0x_) * capture group 1: * **0-9** …
Benny Powers
  • 5,398
  • 4
  • 32
  • 55
1
vote
1 answer

Neovim Treesitter highlighting HTML,JS,PHP in PHP file

I recently switched to Neovim and I tried to configure native LSP with Treesitter. I ran into some wrong highlighting with PHP combined with HTML. Everytime when I write php in html element, closing tag is not highlighted. Treesitter cfg: local…
Dvandy
  • 41
  • 8
1
vote
1 answer

tree-sitter match for similar structures

I'm trying to create a tree-sitter for a Minecraft function grammar. The structure of the language looks like this: command @e[key=value] other args I'm having an issue with the value in the second argument (the target selector) in the above…
theusaf
  • 1,781
  • 1
  • 9
  • 19
1
vote
1 answer

Adding rule to Treesitter LR1 grammar changes precedence

I am trying to get operator precedence correct in a Treesitter grammar. Treesitter is a LR1 parser generator. I have a straightforward artithmetic grammar, which partially looks like this: multiply_expression: $ => prec.left(2, seq( …
Sjoerd
  • 74,049
  • 16
  • 131
  • 175
1
vote
1 answer

Is there a standard treesitter construct for parsing an arbitrary-length list?

One very common parsing scenario in programming languages is an arbitrary-length nonempty list of elements with a separator, for example: [1, 2, 3, 4, 5] f(a, b, c) I've been parsing this in treesitter as follows: list: $ => seq( …
ahelwer
  • 1,441
  • 13
  • 29
1
vote
2 answers

How do I compile tree-sitter parsers?

I'm trying to compile the typescript, tsx, and python parsers for use with neovim, but when I run gcc -o parser.so -shared src/parser.c -Os -I./src as instructed by the tree-sitter tracking issue I get: Undefined symbols for architecture x86_64: …
saltdotac
  • 111
  • 1
  • 3