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
impl GrammarLoader for EmbeddedStdlib
§fn read(&self, base: Option<&str>, path: &str) -> Option<(String, String)>
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.