Skip to main content

ParseSession

Struct ParseSession 

Source
pub struct ParseSession<L>
where L: Language + Send + Sync + 'static,
{ /* private fields */ }
Expand description

A memory pool that manages the lifecycle of parsing generations.

ParseSession handles the double-buffering of memory arenas (Active vs Old) to support efficient incremental reuse. It implements ParseCache.

Implementations§

Source§

impl<L> ParseSession<L>
where L: Language + Send + Sync + 'static,

Source

pub fn new(capacity: usize) -> ParseSession<L>

Creates a new parse session.

Trait Implementations§

Source§

impl<L> Default for ParseSession<L>
where L: Language + Send + Sync + 'static,

Source§

fn default() -> ParseSession<L>

Returns the “default value” for a type. Read more
Source§

impl<L> LexerCache<L> for ParseSession<L>
where L: Language + Send + Sync + 'static,

Source§

fn set_lex_output( &mut self, output: OakDiagnostics<Arc<[Token<<L as Language>::TokenType>]>>, )

Sets the lexed output in the cache. Read more
Source§

fn get_token(&self, index: usize) -> Option<Token<<L as Language>::TokenType>>

Gets a token from the cache by index. Read more
Source§

fn count_tokens(&self) -> usize

Gets the total number of tokens in the cache. Read more
Source§

fn has_tokens(&self) -> bool

Checks if the cache contains any tokens. Read more
Source§

fn get_tokens(&self) -> Option<&[Token<<L as Language>::TokenType>]>

Gets all cached tokens as a slice. Read more
Source§

impl<L> ParseCache<L> for ParseSession<L>
where L: Language + Send + Sync + 'static,

Source§

fn arena(&self) -> &SyntaxArena

Returns the arena for allocating nodes in the current generation.
Source§

fn old_tree(&self) -> Option<&GreenNode<'_, L>>

Returns the root of the previous tree for incremental parsing.
Source§

fn lex_output( &self, ) -> Option<&OakDiagnostics<Arc<[Token<<L as Language>::TokenType>]>>>

Returns the output of the lexing phase.
Source§

fn prepare_generation(&mut self)

Prepares for a new parsing generation (e.g. by swapping arenas).
Source§

fn commit_generation(&self, root: &GreenNode<'_, L>)

Commits the result of a parsing generation.
Source§

impl<L> BuilderCache<L> for ParseSession<L>
where L: Language + Send + Sync + 'static,

Source§

impl<L> Send for ParseSession<L>
where L: Language + Send + Sync + 'static,

Source§

impl<L> Sync for ParseSession<L>
where L: Language + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<L> !Freeze for ParseSession<L>

§

impl<L> !RefUnwindSafe for ParseSession<L>

§

impl<L> Unpin for ParseSession<L>
where <L as Language>::TokenType: Unpin,

§

impl<L> !UnwindSafe for ParseSession<L>

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.