Skip to main content

EmbeddedStdlib

Struct EmbeddedStdlib 

pub struct EmbeddedStdlib;
Expand description

The embedded Lark stdlib: all four lark/grammars/*.lark files (embed all four — %import python.X / %import lark.X are working Lark features via its package loader). Baked in via include_str!; no filesystem needed in native/WASM/C.

Trait Implementations§

§

impl GrammarLoader for EmbeddedStdlib

§

fn read(&self, base: Option<&str>, path: &str) -> Option<(String, String)>

Mirrors FromPackageLoader('lark', ['grammars']).__call__. base = None (library import) searches STDLIB_SEARCH_PATHS, joining os.path.join(dir, path); a hit is an exact match against an embedded resource, returned as the joined path (threaded back as the base for nested imports) + its text.

base = Some(_) always misses. FromPackageLoader raises IOError unless base_path is a PackageResource whose pkg_name matches — a plain string dirname is always rejected. The core only ever constructs string-dirname bases (unpack_import derives Some(dirname(origin)) for a relative import), never a PackageResource, and no embedded grammar performs a relative import (lark.lark’s %import common is a library import → base=None), so the Some arm can never legitimately hit; taking it would false-route a user’s relative import to the embedded stdlib.

Auto Trait Implementations§

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 = !

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.