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.
Questions tagged [treesitter]
81 questions
0
votes
1 answer
How to do case-insensitive query in tree-sitter
I'm working on trying to create and use tree-sitter grammar in a language server I am implementing in order to support features like finding all references of a variable. Given the grammar I would be able to write a query to find all of the…

Christopher Wells
- 1,918
- 1
- 15
- 20
0
votes
1 answer
In a tree-sitter grammar, is it possible for operator precedence/associativity conflict to cause a runtime parse failure?
Consider an infix operator like subset (⊂). The subset operator is not associative, because its result (a boolean) is not itself a set and so cannot be fed into one or another side of the subset operator. Consider:
S ⊂ T ⊂ M
Ideally this would be a…

ahelwer
- 1,441
- 13
- 29
0
votes
1 answer
In a tree-sitter grammar, how do I match a non-delimited list of values in a non-associative way?
For example, consider the following grammar:
source_file: $ => $._expression,
_expression: $ => choice(
$.identifier,
$.operator
),
identifier: $ => /\w*[A-Za-z]\w*/,
operator: $ => seq(
repeat1(seq($._expression, '\\X')),
…

ahelwer
- 1,441
- 13
- 29
0
votes
1 answer
Treesitter produces error nodes even though other match seems possible
I am trying to parse a language with identifiers and also literals.
b
b""
Here b is an indentifier, and b"" is a literal (also possible would be e.g., b"foo").
I have the following simplified grammar:
module.exports = grammar({
name: 'foo',
…

Benjamin Bannier
- 55,163
- 11
- 60
- 80
0
votes
1 answer
Atom editor - not receiving the correct scopes from tree sitter parser
I have developed a format called PTL. I would like to have syntax highlighting in Atom for it, so I followed the appropriate guides to create a working tree-sitter parser for it. With a colossal amount of debugging, I managed to get the parser…

wvn
- 624
- 5
- 12
0
votes
1 answer
Is there any way to split a treesitter grammar into multiple files?
I'm parsing a fairly simple language but my grammar is already becoming unwieldy in a single file. Is there any way to split it up into multiple files?

ahelwer
- 1,441
- 13
- 29