class

TreeSitter::Parser

Inherits Reference / Object

A Parser is a stateful object that can be assigned a Language and used to produce a Tree based on some source code.

Constructors

new(language_name : String)
Source
new(*, language : Language | Nil = nil)

Create a new parser.

Source

Instance methods

language

Get the parser's current language.

Source
language=(language : Language) : Language

Set the language that the parser should use for parsing.

Raises Error if the language version is incompatible with treesitter library.

Source
parse(old_tree : Tree | Nil, io : IO) : Tree | Nil
Source
parse(old_tree : Tree | Nil, string : String) : Tree
Source
parse(old_tree : Tree | Nil, &block : ReadProc) : Tree
Source
parse?(old_tree : Tree | Nil, io : IO) : Tree | Nil
Source
parse?(old_tree : Tree | Nil, string : String) : Tree | Nil
Source
parse?(old_tree : Tree | Nil, &block : ReadProc) : Tree | Nil
Source
reset

Instruct the parser to start the next parse from the beginning.

If the parser previously failed because of a timeout or a cancellation, then by default, it will resume where it left off on the next call to #parse or other parsing methods. If you don't want to resume, and instead intend to use this parser to parse some other document, you must call #reset first.

Source

Nested types