NAME
Text::Treesitter::Language
- represents a tree-sitter language grammar
SYNOPSIS
TODO
DESCRIPTION
Instances of this class represent an entire language grammar specification. Typically an application will load just one of these for the lifetime of its operation; or at least, just one per type of language being parsed.
UTILITY FUNCTIONS
These utility functions are not exported, and must be called fully-qualified.
build
Text::Treesitter::Language::build( $output, @dirs );
Requests that a language grammar repository directory (or several) be compiled into an object file that can later be loaded.
load
$lang = Text::Treesitter::Language::load( $libfile, $name );
Attempts to actually load the grammar specification from the object file. The object file must have been previously built (either by calling "build", or obtained in some other way).
An instance of Text::Treesitter::Language
is returned. This can be passed to the set_language
method of a Text::Treesitter::Parser instance.
METHODS
symbol_count
$count = $lang->symbol_count;
Returns the number of symbols defined in the language.
symbols
@symbols = $lang->symbols;
Returns a list of Symbol instances, in id order. Each will be an instance of a class having the following accessors::
$symbol->id
$symbol->name
$symbol->type_is_regular
$symbol->type_is_anonymous
$symbol->type_is_auxiliary
field_count
$count = $lang->field_count;
Returns the number of fields defined in the language.
fields
@fields = $lang->fields;
Returns a list of Field instances, in id order. Each will be an instance of a class having the following accessors:
$field->id
$field->name
TODO
The following C library functions are currently unhandled:
ts_language_symbol_for_name
ts_language_field_id_for_name
ts_language_version
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>