pub struct DatasetRuleResolver { /* private fields */ }Expand description
In-memory resolver caching syntax rules, named types, and script mappings.
Implementations§
Source§impl DatasetRuleResolver
impl DatasetRuleResolver
Sourcepub fn load_from_embedded_dataset() -> Result<DatasetRuleResolver, Error>
pub fn load_from_embedded_dataset() -> Result<DatasetRuleResolver, Error>
Builds a resolver by indexing the CSV fixture dataset
in src/formats/dcdata/data-src/.
Used by the consistency test verifying that the seed graph syntax resolver is up to date with the CSV dataset.
§Errors
Returns an error if the fixture dataset is missing or invalid.
Sourcepub fn load_from_dataset(
dc_defns: &[DcDefn],
format_defns: &[DcDefn],
named_types_csv: Option<&[u8]>,
) -> Result<DatasetRuleResolver, Error>
pub fn load_from_dataset( dc_defns: &[DcDefn], format_defns: &[DcDefn], named_types_csv: Option<&[u8]>, ) -> Result<DatasetRuleResolver, Error>
Builds a resolver by indexing syntax rules directly from parsed dataset definitions.
This is the CSV-driven authoritative indexing path used by
consistency tests verifying that the seed graph syntax resolver
matches the CSV dataset. dc_defns must be sorted by long ID so
delimiter precedence is deterministic (matching
lookup::get_all_dc_defns).
§Errors
Returns an error with CSV row and named type context when a named type record or its grammar is invalid.
Source§impl DatasetRuleResolver
impl DatasetRuleResolver
Sourcepub fn new() -> DatasetRuleResolver
pub fn new() -> DatasetRuleResolver
Creates an empty resolver instance.
Sourcepub fn set_seed_graph(&mut self, seed_graph: Arc<SeedGraphIndex>)
pub fn set_seed_graph(&mut self, seed_graph: Arc<SeedGraphIndex>)
Binds a crate::seed_graph::SeedGraphIndex snapshot to this resolver.
Sourcepub fn add_subtype(&mut self, sub_token: u128, super_token: u128)
pub fn add_subtype(&mut self, sub_token: u128, super_token: u128)
Registers a direct subtype relationship (sub_token is a subtype of super_token).
Sourcepub fn add_rule(&mut self, target: CharTarget, rule: DcSyntaxRule)
pub fn add_rule(&mut self, target: CharTarget, rule: DcSyntaxRule)
Registers a syntax rule for a character target.
Sourcepub fn add_named_type(&mut self, name: String, pattern: SyntaxPattern)
pub fn add_named_type(&mut self, name: String, pattern: SyntaxPattern)
Registers a pattern definition for a named type.
Sourcepub fn add_script_char(&mut self, script: String, token: u128)
pub fn add_script_char(&mut self, script: String, token: u128)
Registers a character token under a script name.
Sourcepub fn register_closing_delimiter(
&mut self,
closer_token: u128,
opener: CharTarget,
)
pub fn register_closing_delimiter( &mut self, closer_token: u128, opener: CharTarget, )
Registers a delimiter token as closing an opener target.
Sourcepub fn register_equivalence(&mut self, alias_token: u128, canonical_token: u128)
pub fn register_equivalence(&mut self, alias_token: u128, canonical_token: u128)
Registers a semantic equivalence mapping alias_token to canonical_token.
Sourcepub fn register_deprecated(
&mut self,
target: CharTarget,
preferred: Option<CharTarget>,
)
pub fn register_deprecated( &mut self, target: CharTarget, preferred: Option<CharTarget>, )
Registers a deprecated target and its optional preferred replacement.
Sourcepub fn rebuild_framing_and_wrapper_tables(&mut self)
pub fn rebuild_framing_and_wrapper_tables(&mut self)
Rebuilds the cached framing-shape and special-wrapper lookup tables from the currently registered rules, delimiters, and equivalences.
Sourcepub fn from_seed_graph_arc(
index: Arc<SeedGraphIndex>,
) -> Result<DatasetRuleResolver, Error>
pub fn from_seed_graph_arc( index: Arc<SeedGraphIndex>, ) -> Result<DatasetRuleResolver, Error>
Builds a resolver directly from a shared runtime SeedGraphIndex
(data/graph/85899_34592.ctbnbdl) without cloning it.
Sourcepub fn from_seed_graph(
index: &SeedGraphIndex,
) -> Result<DatasetRuleResolver, Error>
pub fn from_seed_graph( index: &SeedGraphIndex, ) -> Result<DatasetRuleResolver, Error>
Builds a resolver directly from the runtime SeedGraphIndex (data/graph/85899_34592.ctbnbdl).
Sourcepub fn load_from_seed_graph() -> Result<DatasetRuleResolver, Error>
pub fn load_from_seed_graph() -> Result<DatasetRuleResolver, Error>
Loads a DatasetRuleResolver from the process-wide shared SeedGraphIndex
(data/graph/85899_34592.ctbnbdl).
Sourcepub fn load_at_most_recent(
most_recent_node_id: u128,
) -> Result<DatasetRuleResolver, Error>
pub fn load_at_most_recent( most_recent_node_id: u128, ) -> Result<DatasetRuleResolver, Error>
Loads a DatasetRuleResolver reflecting the System-block graph state as of
most_recent_node_id (Dc 641 "Global graph system block most recent node ID at time of document creation").
Source§impl DatasetRuleResolver
impl DatasetRuleResolver
Sourcepub fn load() -> DatasetRuleResolver
pub fn load() -> DatasetRuleResolver
Loads the authoritative resolver state from the bundled runtime seed graph
(data/graph/85899_34592.ctbnbdl via SeedGraphIndex::shared()).
Trait Implementations§
Source§impl Clone for DatasetRuleResolver
impl Clone for DatasetRuleResolver
Source§fn clone(&self) -> DatasetRuleResolver
fn clone(&self) -> DatasetRuleResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DatasetRuleResolver
impl Debug for DatasetRuleResolver
Source§impl Default for DatasetRuleResolver
impl Default for DatasetRuleResolver
Source§fn default() -> DatasetRuleResolver
fn default() -> DatasetRuleResolver
Source§impl SyntaxRuleResolver for DatasetRuleResolver
impl SyntaxRuleResolver for DatasetRuleResolver
Source§fn seed_graph(&self) -> Option<&SeedGraphIndex>
fn seed_graph(&self) -> Option<&SeedGraphIndex>
SeedGraphIndex when backed by the System-block seed graph.Source§fn is_subtype_of(&self, sub_token: u128, super_token: u128) -> bool
fn is_subtype_of(&self, sub_token: u128, super_token: u128) -> bool
sub_token is equivalent to or a transitive subtype (Dc 587) of super_token.Source§fn canonical_token(&self, token: u128) -> u128
fn canonical_token(&self, token: u128) -> u128
token itself if no <equiv> alias is defined.Source§fn unicode_text_mapping(&self, token: u128, approximate: bool) -> Option<&str>
fn unicode_text_mapping(&self, token: u128, approximate: bool) -> Option<&str>
Source§fn equivalent_short_dc_for_unicode(
&self,
tokens: &[u128],
) -> Option<(u128, usize)>
fn equivalent_short_dc_for_unicode( &self, tokens: &[u128], ) -> Option<(u128, usize)>
tokens that has an exact (<equiv>)
mapping from an already-assigned short Dc (< 641), returning
(short_dc_global_id, consumed_token_count).Source§fn is_equivalent_to(&self, token: u128, canonical: u128) -> bool
fn is_equivalent_to(&self, token: u128, canonical: u128) -> bool
Source§fn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>
fn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>
Source§fn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>
fn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>
Source§fn matches_script(&self, script_name: &str, token: u128) -> bool
fn matches_script(&self, script_name: &str, token: u128) -> bool
Source§fn may_match_any_script(&self, token: u128) -> bool
fn may_match_any_script(&self, token: u128) -> bool
token is known not to belong to any script.Source§fn has_script(&self, script_name: &str) -> bool
fn has_script(&self, script_name: &str) -> bool
Source§fn matches_named_type_starter(&self, name: &str, token: u128) -> bool
fn matches_named_type_starter(&self, name: &str, token: u128) -> bool
token can appear as the leading token of the named construct name.Source§fn closing_opener_for(&self, token: u128) -> Option<&CharTarget>
fn closing_opener_for(&self, token: u128) -> Option<&CharTarget>
Source§fn closer_for_opener(&self, opener: &CharTarget) -> Option<u128>
fn closer_for_opener(&self, opener: &CharTarget) -> Option<u128>
Source§fn is_deprecated(&self, target: &CharTarget) -> bool
fn is_deprecated(&self, target: &CharTarget) -> bool
Source§fn preferred_replacement(&self, target: &CharTarget) -> Option<&CharTarget>
fn preferred_replacement(&self, target: &CharTarget) -> Option<&CharTarget>
<prefer>...) for a deprecated target, if any.Source§fn container_header_elements(&self, opener: &CharTarget) -> &[SyntaxElement]
fn container_header_elements(&self, opener: &CharTarget) -> &[SyntaxElement]
~ and the container body/closer
(for example, [number $length]? [type] for 310, or [format] for 511).Source§fn trailing_after_closer(&self, opener: &CharTarget) -> &[SyntaxElement]
fn trailing_after_closer(&self, opener: &CharTarget) -> &[SyntaxElement]
[545:] after 544 in 543’s rule :~ [^544]+ 544 [545:]).Source§fn resolve_infix_rule(
&self,
op_token: u128,
) -> Option<(&[SyntaxElement], &[SyntaxElement])>
fn resolve_infix_rule( &self, op_token: u128, ) -> Option<(&[SyntaxElement], &[SyntaxElement])>
(lhs_elements, rhs_elements) where ~ is preceded
by a left-hand operand (for example, Dc 269: :[identifier $ident] ~ [value $val]).Source§fn is_opaque_container(&self, opener_token: u128) -> bool
fn is_opaque_container(&self, opener_token: u128) -> bool
opener_token is a lexical/opaque payload
container (such as numbers, binary encapsulation, comments, literals, type definitions,
or identifiers) whose interior tokens are not recursively parsed as child statements.Source§fn framing_shape(&self, token: u128) -> FramingShape
fn framing_shape(&self, token: u128) -> FramingShape
token.Source§fn is_special_wrapper_token(&self, token: u128) -> bool
fn is_special_wrapper_token(&self, token: u128) -> bool
token is a wrapper construct (OptionalPresent,
OptionalAbsent, or is_representation_set) handled transparently by pattern evaluation.Source§fn is_splice_trigger_token(&self, token: u128) -> bool
fn is_splice_trigger_token(&self, token: u128) -> bool
token emits into the evaluated stream.Source§fn is_plain_atom_dc(&self, token: u128) -> bool
fn is_plain_atom_dc(&self, token: u128) -> bool
token matches the single-token branch of [atom_dc]
(i.e. is not in the negated delimiter/operator exclusion set of atom_dc).Source§fn token_fills_role(&self, token: u128, role: DcRole) -> bool
fn token_fills_role(&self, token: u128, role: DcRole) -> bool
token fills the designated syntactic or semantic role.Source§fn resolve_rule_tokens(&self, target: &CharTarget) -> Option<&[DcShorthand]>
fn resolve_rule_tokens(&self, target: &CharTarget) -> Option<&[DcShorthand]>
.Semantic:Pattern token sequence (Dc 594 "Syntax rule") for target
directly from the seed graph without constructing a Rust SyntaxPattern AST.Source§fn resolve_named_type_tokens(&self, name: &str) -> Option<&[DcShorthand]>
fn resolve_named_type_tokens(&self, name: &str) -> Option<&[DcShorthand]>
.Semantic:Pattern token sequence (Dc 594 "Syntax rule") for a named
construct directly from the seed graph without constructing a Rust SyntaxPattern AST.Source§fn resolve_wasm_definition_tokens(&self, token: u128) -> Option<&[DcShorthand]>
fn resolve_wasm_definition_tokens(&self, token: u128) -> Option<&[DcShorthand]>
.WASM program (Dc 1927 "Begin WASM program"..Dc 1928 "End WASM program")
or wasm_routine definition attached to token (or its canonical equivalent) in the seed graph.Source§fn resolve_wasm_definition_tokens_in_context(
&self,
token: u128,
context_tokens: &[DcShorthand],
) -> Option<&[DcShorthand]>
fn resolve_wasm_definition_tokens_in_context( &self, token: u128, context_tokens: &[DcShorthand], ) -> Option<&[DcShorthand]>
Dc 646 "In context of") .WASM program attached to
token (or its canonical equivalent) matching context_tokens in the seed graph.Source§fn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize>
fn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize>
~) in a format’s sequence syntax rule.Source§fn resolve_named_type_with_arg(
&self,
name: &str,
arg: Option<&SubtypeConstraint>,
) -> Option<SyntaxPattern>
fn resolve_named_type_with_arg( &self, name: &str, arg: Option<&SubtypeConstraint>, ) -> Option<SyntaxPattern>
Source§fn base64_digit_value(&self, token: u128) -> Option<u8>
fn base64_digit_value(&self, token: u128) -> Option<u8>
0..=63) or padding sentinel (64)
if token (or its canonical equivalent) represents a Base64 encapsulation character.Source§fn is_representation_set(&self, token: u128) -> bool
fn is_representation_set(&self, token: u128) -> bool
Source§fn is_representation_header_or_separator(&self, token: u128) -> bool
fn is_representation_header_or_separator(&self, token: u128) -> bool
Source§fn is_assignment_construct(&self, token: u128) -> bool
fn is_assignment_construct(&self, token: u128) -> bool
token is an assignment construct (DcRole::LangAssign, an infix assignment
operator, or a syntax rule whose action is lang.assign).Source§fn token_satisfies_type(
&self,
tok: u128,
req_name: &str,
req_subtype: Option<&SubtypeConstraint>,
) -> bool
fn token_satisfies_type( &self, tok: u128, req_name: &str, req_subtype: Option<&SubtypeConstraint>, ) -> bool
tok satisfies the type requirement (req_name, req_subtype).Source§fn resolve_list_element_term(
&self,
subtype: Option<&SubtypeConstraint>,
) -> Option<SyntaxTerm>
fn resolve_list_element_term( &self, subtype: Option<&SubtypeConstraint>, ) -> Option<SyntaxTerm>
SyntaxTerm for a [list:<subtype>] constraint.Auto Trait Implementations§
impl Freeze for DatasetRuleResolver
impl RefUnwindSafe for DatasetRuleResolver
impl Send for DatasetRuleResolver
impl Sync for DatasetRuleResolver
impl Unpin for DatasetRuleResolver
impl UnwindSafe for DatasetRuleResolver
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);