class TreeSitter::Parser
- TreeSitter::Parser
- Reference
- Object
Overview
A Parser
is a stateful object that can be assigned a Language
and used to produce a Tree
based on some source code.
Defined in:
tree_sitter/parser.crConstructors
- .new(language_name : String)
-
.new(*, language : Language | Nil = nil)
Create a new parser.
Instance Method Summary
-
#language : Language
Get the parser's current language.
-
#language=(language : Language) : Language
Set the language that the parser should use for parsing.
- #parse(old_tree : Tree | Nil, io : IO) : Tree | Nil
- #parse(old_tree : Tree | Nil, string : String) : Tree
- #parse(old_tree : Tree | Nil, &block : ReadProc) : Tree
- #parse?(old_tree : Tree | Nil, io : IO) : Tree | Nil
- #parse?(old_tree : Tree | Nil, string : String) : Tree | Nil
- #parse?(old_tree : Tree | Nil, &block : ReadProc) : Tree | Nil
-
#print_dot_graphs(io : IO::FileDescriptor | Nil) : Nil
Set the file descriptor to which the parser should write debugging graphs during parsing.
-
#reset
Instruct the parser to start the next parse from the beginning.
Constructor Detail
Instance Method Detail
Set the language that the parser should use for parsing.
Raises Error
if the language version is incompatible with treesitter library.
Set the file descriptor to which the parser should write debugging graphs
during parsing. The graphs are formatted in the DOT language. You may want
to pipe these graphs directly to a dot(1)
process in order to generate
SVG output. You can turn off this logging by passing nil.
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.