API extensions
This commit is contained in:
parent
08f4e82bb2
commit
c47e217e73
14 changed files with 741 additions and 29 deletions
|
|
@ -1,5 +1,6 @@
|
|||
/* automatically generated by rust-bindgen 0.66.1 */
|
||||
|
||||
pub type TSStateId = u16;
|
||||
pub type TSSymbol = u16;
|
||||
pub type TSFieldId = u16;
|
||||
#[repr(C)]
|
||||
|
|
@ -27,6 +28,11 @@ pub struct TSQuery {
|
|||
pub struct TSQueryCursor {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct TSLookaheadIterator {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
pub const TSInputEncoding_TSInputEncodingUTF8: TSInputEncoding = 0;
|
||||
pub const TSInputEncoding_TSInputEncodingUTF16: TSInputEncoding = 1;
|
||||
pub type TSInputEncoding = ::std::os::raw::c_uint;
|
||||
|
|
@ -326,6 +332,14 @@ extern "C" {
|
|||
#[doc = " Check if the node is a syntax error or contains any syntax errors."]
|
||||
pub fn ts_node_has_error(arg1: TSNode) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Check if the node is a syntax error."]
|
||||
pub fn ts_node_is_error(arg1: TSNode) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get this node's parse state."]
|
||||
pub fn ts_node_parse_state(arg1: TSNode) -> TSStateId;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the node's immediate parent."]
|
||||
pub fn ts_node_parent(arg1: TSNode) -> TSNode;
|
||||
|
|
@ -427,6 +441,10 @@ extern "C" {
|
|||
#[doc = " Re-initialize a tree cursor to start at a different node."]
|
||||
pub fn ts_tree_cursor_reset(arg1: *mut TSTreeCursor, arg2: TSNode);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Re-initialize a tree cursor to the same position as another cursor.\n\n Unlike `ts_tree_cursor_reset`, this will not lose parent information and\n allows reusing already created cursors."]
|
||||
pub fn ts_tree_cursor_reset_to(arg1: *mut TSTreeCursor, arg2: *const TSTreeCursor);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the tree cursor's current node."]
|
||||
pub fn ts_tree_cursor_current_node(arg1: *const TSTreeCursor) -> TSNode;
|
||||
|
|
@ -450,9 +468,16 @@ extern "C" {
|
|||
pub fn ts_tree_cursor_goto_next_sibling(arg1: *mut TSTreeCursor) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Move the cursor to the first child of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false`\n if there were no children."]
|
||||
#[doc = " Move the cursor to the previous sibling of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false` if\n there was no previous sibling node."]
|
||||
pub fn ts_tree_cursor_goto_previous_sibling(arg1: *mut TSTreeCursor) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Move the cursor to the first/last child of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false`\n if there were no children."]
|
||||
pub fn ts_tree_cursor_goto_first_child(arg1: *mut TSTreeCursor) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn ts_tree_cursor_goto_last_child(arg1: *mut TSTreeCursor) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Move the cursor to the node that is the nth descendant of\n the original node that the cursor was constructed with, where\n zero represents the original node itself."]
|
||||
pub fn ts_tree_cursor_goto_descendant(arg1: *mut TSTreeCursor, arg2: u32);
|
||||
|
|
@ -608,6 +633,10 @@ extern "C" {
|
|||
#[doc = " Get the number of distinct node types in the language."]
|
||||
pub fn ts_language_symbol_count(arg1: *const TSLanguage) -> u32;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the number of valid states in this language."]
|
||||
pub fn ts_language_state_count(arg1: *const TSLanguage) -> u32;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get a node type string for the given numerical id."]
|
||||
pub fn ts_language_symbol_name(
|
||||
|
|
@ -651,6 +680,52 @@ extern "C" {
|
|||
#[doc = " Get the ABI version number for this language. This version number is used\n to ensure that languages were generated by a compatible version of\n Tree-sitter.\n\n See also `ts_parser_set_language`."]
|
||||
pub fn ts_language_version(arg1: *const TSLanguage) -> u32;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the next parse state. Combine this with lookahead iterators to generate\n completion suggestions or valid symbols in error nodes."]
|
||||
pub fn ts_language_next_state(
|
||||
arg1: *const TSLanguage,
|
||||
arg2: TSStateId,
|
||||
arg3: TSSymbol,
|
||||
) -> TSStateId;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Create a new lookahead iterator for the given language and parse state.\n\n This returns `NULL` if state is invalid for the language.\n\n Repeatedly using `ts_lookahead_iterator_advance` and\n `ts_lookahead_iterator_current_symbol` will generate valid symbols in the\n given parse state. Newly created lookahead iterators will contain the `ERROR`\n symbol.\n\n Lookahead iterators can be useful to generate suggestions and improve syntax\n error diagnostics. To get symbols valid in an ERROR node, use the lookahead\n iterator on its first leaf node state. For `MISSING` nodes, a lookahead\n iterator created on the previous non-extra leaf node may be appropriate."]
|
||||
pub fn ts_lookahead_iterator_new(
|
||||
arg1: *const TSLanguage,
|
||||
arg2: TSStateId,
|
||||
) -> *mut TSLookaheadIterator;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Delete a lookahead iterator freeing all the memory used."]
|
||||
pub fn ts_lookahead_iterator_delete(arg1: *mut TSLookaheadIterator);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Reset the lookahead iterator to another state.\n\n This returns `true` if the iterator was reset to the given state and `false`\n otherwise."]
|
||||
pub fn ts_lookahead_iterator_reset_state(
|
||||
arg1: *mut TSLookaheadIterator,
|
||||
arg2: TSStateId,
|
||||
) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Reset the lookahead iterator.\n\n This returns `true` if the language was set successfully and `false`\n otherwise."]
|
||||
pub fn ts_lookahead_iterator_reset(
|
||||
arg1: *mut TSLookaheadIterator,
|
||||
arg2: *const TSLanguage,
|
||||
arg3: TSStateId,
|
||||
) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the current language of the lookahead iterator."]
|
||||
pub fn ts_lookahead_iterator_language(arg1: *const TSLookaheadIterator) -> *const TSLanguage;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Advance the lookahead iterator to the next symbol.\n\n This returns `true` if there is a new symbol and `false` otherwise."]
|
||||
pub fn ts_lookahead_iterator_advance(arg1: *mut TSLookaheadIterator) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the current symbol of the lookahead iterator;"]
|
||||
pub fn ts_lookahead_iterator_current_symbol(arg1: *const TSLookaheadIterator) -> TSSymbol;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Set the allocation functions used by the library.\n\n By default, Tree-sitter uses the standard libc allocation functions,\n but aborts the process when an allocation fails. This function lets\n you supply alternative allocation functions at runtime.\n\n If you pass `NULL` for any parameter, Tree-sitter will switch back to\n its default implementation of that function.\n\n If you call this function after the library has already been used, then\n you must ensure that either:\n 1. All the existing objects have been freed.\n 2. The new allocator shares its state with the old one, so it is capable\n of freeing memory that was allocated by the old allocator."]
|
||||
pub fn ts_set_allocator(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue