pub struct ParseContext { /* private fields */ }Expand description
Immutable parse context owning an isolated knowledge base.
A ParseContext is the main integration surface for callers that need to
freeze a fully-built knowledge base, query metadata, and parse LaTeX
formulas repeatedly.
§Construction
| Constructor | Loaded knowledge |
|---|---|
empty() | Nothing |
from_packages() | Named packages only |
Default::default() | Default runtime packages |
shared() | Same as above, lazily cached &'static ref |
Implementations§
Source§impl ParseContext
impl ParseContext
pub fn builder() -> ParseContextBuilder
pub fn mutation_summary(&self) -> &MutationSummary
pub fn enabled_packages(&self) -> &[PackageName]
pub fn has_enabled_package(&self, package: PackageName) -> bool
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Build an empty context with no package specs loaded.
Useful as a blank slate when every definition will be injected manually.
Sourcepub fn from_packages(packages: &[&str]) -> Self
pub fn from_packages(packages: &[&str]) -> Self
Build a context from an explicit list of package names. The listed packages are imported in canonical order.
§Panics
Panics if any package name is unrecognized. Use try_from_packages
for fallible loading.
Sourcepub fn try_from_packages(packages: &[&str]) -> Result<Self, PackageLoadError>
pub fn try_from_packages(packages: &[&str]) -> Result<Self, PackageLoadError>
Fallible variant of from_packages.
Returns PackageLoadError instead of panicking when a package name
is unrecognized.
Borrow the lazily-initialized default-package context.
This is the cheapest way to parse with the default knowledge base: the context is built once on first call and shared for the process lifetime.
Sourcepub fn is_delimiter_control(&self, name: &str) -> bool
pub fn is_delimiter_control(&self, name: &str) -> bool
Check whether name is a registered delimiter control sequence.
Sourcepub fn lookup_delimiter_control(&self, name: &str) -> Option<&'static str>
pub fn lookup_delimiter_control(&self, name: &str) -> Option<&'static str>
Look up a delimiter control by name, returning the interned name.
pub fn lookup_delimiter( &self, name: &str, is_control_sequence: bool, mode: ContentMode, ) -> Option<&ActiveDelimiterRecord>
Sourcepub fn parse(&self, src: &str, config: &ParseConfig) -> ParseResult
pub fn parse(&self, src: &str, config: &ParseConfig) -> ParseResult
Parse a LaTeX formula and return a unified output.
Uses chumsky’s output+errors semantics so that a partial syntax tree can coexist with diagnostics.
Sourcepub fn kb_for(&self, mode: ContentMode) -> &KnowledgeBase
pub fn kb_for(&self, mode: ContentMode) -> &KnowledgeBase
Look up the active command metadata for name.
The active entry may come from an explicit command definition or a
character-derived zero-arg view. Returns None if the name is unknown
or has been suppressed.
pub fn math_kb(&self) -> &KnowledgeBase
pub fn text_kb(&self) -> &KnowledgeBase
Sourcepub fn lookup_command(
&self,
name: &str,
mode: ContentMode,
) -> Option<&ActiveCommandRecord>
pub fn lookup_command( &self, name: &str, mode: ContentMode, ) -> Option<&ActiveCommandRecord>
Look up the active command metadata for name in the selected lane.
Sourcepub fn lookup_explicit_command(
&self,
name: &str,
mode: ContentMode,
) -> Option<&ActiveCommandRecord>
pub fn lookup_explicit_command( &self, name: &str, mode: ContentMode, ) -> Option<&ActiveCommandRecord>
Look up only the explicit (non-character-derived) command for name.
Sourcepub fn lookup_character(
&self,
name: &str,
mode: ContentMode,
) -> Option<&ActiveCharacterRecord>
pub fn lookup_character( &self, name: &str, mode: ContentMode, ) -> Option<&ActiveCharacterRecord>
Look up character metadata for a control sequence name.
Sourcepub fn lookup_env(
&self,
name: &str,
mode: ContentMode,
) -> Option<&ActiveEnvironmentRecord>
pub fn lookup_env( &self, name: &str, mode: ContentMode, ) -> Option<&ActiveEnvironmentRecord>
Look up environment metadata by name.
pub fn knows_command_name(&self, name: &str) -> bool
pub fn knows_env_name(&self, name: &str) -> bool
pub fn knows_character_name(&self, name: &str) -> bool
Trait Implementations§
Source§impl Clone for ParseContext
impl Clone for ParseContext
Source§fn clone(&self) -> ParseContext
fn clone(&self) -> ParseContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more