pub struct SyntaxRuntimeResolver { /* private fields */ }Expand description
Runtime resolver providing syntax rule lookups, dynamic <equiv> overlays,
and custom DcRole classifications for Document Character formats and streams.
Implementations§
Source§impl SyntaxRuntimeResolver
impl SyntaxRuntimeResolver
Sourcepub fn new(base: Arc<dyn SyntaxRuleResolver + Send + Sync>) -> Self
pub fn new(base: Arc<dyn SyntaxRuleResolver + Send + Sync>) -> Self
Creates a new SyntaxRuntimeResolver wrapping a base SyntaxRuleResolver.
Sourcepub fn base(&self) -> &dyn SyntaxRuleResolver
pub fn base(&self) -> &dyn SyntaxRuleResolver
Returns a reference to the underlying base SyntaxRuleResolver.
Sourcepub fn register_equivalence(&mut self, token: u128, canonical_target: u128)
pub fn register_equivalence(&mut self, token: u128, canonical_target: u128)
Registers a runtime <equiv> pair mapping token to canonical_target.
The registered token automatically inherits the target’s syntax rule,
@closes delimiter pairing, opaque container status, and DcRole
memberships.
Sourcepub fn register_role(&mut self, token: u128, role: DcRole)
pub fn register_role(&mut self, token: u128, role: DcRole)
Registers a custom DcRole membership for token.
Sourcepub fn register_closing_pair(&mut self, opener: CharTarget, closer: u128)
pub fn register_closing_pair(&mut self, opener: CharTarget, closer: u128)
Registers an opener/closer delimiter pair.
Sourcepub fn register_rule(&mut self, target: CharTarget, rule: DcSyntaxRule)
pub fn register_rule(&mut self, target: CharTarget, rule: DcSyntaxRule)
Registers a custom syntax rule for target.
Sourcepub fn register_opaque_container(&mut self, opener_token: u128)
pub fn register_opaque_container(&mut self, opener_token: u128)
Marks opener_token as an opaque/lexical container opener.
Sourcepub fn register_wasm_definition(
&mut self,
token: u128,
wasm_tokens: Vec<DcShorthand>,
)
pub fn register_wasm_definition( &mut self, token: u128, wasm_tokens: Vec<DcShorthand>, )
Registers a .WASM program (Dc 1927 "Begin WASM program"..Dc 1928 "End WASM program")
or wasm_routine definition for token, marking token as an evaluable expression starter.
Trait Implementations§
Source§impl Clone for SyntaxRuntimeResolver
impl Clone for SyntaxRuntimeResolver
Source§fn clone(&self) -> SyntaxRuntimeResolver
fn clone(&self) -> SyntaxRuntimeResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SyntaxRuntimeResolver
impl Debug for SyntaxRuntimeResolver
Source§impl Default for SyntaxRuntimeResolver
impl Default for SyntaxRuntimeResolver
Source§impl SyntaxRuleResolver for SyntaxRuntimeResolver
impl SyntaxRuleResolver for SyntaxRuntimeResolver
Source§fn seed_graph(&self) -> Option<&SeedGraphIndex>
fn seed_graph(&self) -> Option<&SeedGraphIndex>
SeedGraphIndex when backed by the System-block seed graph.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 canonical_token(&self, token: u128) -> u128
fn canonical_token(&self, token: u128) -> u128
token itself if no <equiv> alias is defined.Source§fn is_equivalent_to(&self, a: u128, b: u128) -> bool
fn is_equivalent_to(&self, a: u128, b: u128) -> bool
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(&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 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 matches_script(&self, script_name: &str, token: u128) -> bool
fn matches_script(&self, script_name: &str, token: u128) -> bool
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 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 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 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 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 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 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 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_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 SyntaxRuntimeResolver
impl !RefUnwindSafe for SyntaxRuntimeResolver
impl Send for SyntaxRuntimeResolver
impl Sync for SyntaxRuntimeResolver
impl Unpin for SyntaxRuntimeResolver
impl !UnwindSafe for SyntaxRuntimeResolver
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);