Parser

Struct Parser 

Source
#[repr(transparent)]
pub struct Parser<Root: Node<'static>>(pub Parser, _);
Expand description

A stateful object that this is used to produce a tree based on some source code.

Tuple Fields§

§0: Parser

Implementations§

Source§

impl<Root: Node<'static>> Parser<Root>

Source

pub fn wrap(parser: Parser) -> Self

Convert a tree-sitter parser into a typed parser by specifying the correct root node type.

This will succeed even if Root is not the language’s root node, because Tree::root_node checks that the root node is the correct type.

Source

pub fn wrap_ref(parser: &Parser) -> &Self

Version of wrap for an immutable reference.

Source

pub fn wrap_mut(parser: &mut Parser) -> &mut Self

Version of wrap for a mutable reference.

Source

pub fn new(language: &Language) -> Result<Self, LanguageError>

Create a new parser for the given language. See tree_sitter::Parser::set_language

Source

pub fn set_included_ranges( &mut self, ranges: &[Range], ) -> Result<(), IncludedRangesError>

Set the ranges of text the parser should include when parsing. See tree_sitter::Parser::set_included_ranges

Source

pub fn parse( &mut self, text: impl AsRef<[u8]>, old_tree: Option<&Tree<Root>>, ) -> Result<Tree<Root>, ()>

Parse a byte string. See tree_sitter::Parser::parse

Auto Trait Implementations§

§

impl<Root> Freeze for Parser<Root>

§

impl<Root> RefUnwindSafe for Parser<Root>
where Root: RefUnwindSafe,

§

impl<Root> Send for Parser<Root>
where Root: Send,

§

impl<Root> Sync for Parser<Root>
where Root: Sync,

§

impl<Root> Unpin for Parser<Root>
where Root: Unpin,

§

impl<Root> UnwindSafe for Parser<Root>
where Root: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.