pub trait SyntaxRuleResolver {
Show 37 methods
// Required methods
fn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>;
fn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>;
fn matches_script(&self, script_name: &str, token: u128) -> bool;
// Provided methods
fn seed_graph(&self) -> Option<&SeedGraphIndex> { ... }
fn resolve_rule_tokens(&self, target: &CharTarget) -> Option<&[DcShorthand]> { ... }
fn resolve_named_type_tokens(&self, name: &str) -> Option<&[DcShorthand]> { ... }
fn resolve_wasm_definition_tokens(
&self,
token: u128,
) -> Option<&[DcShorthand]> { ... }
fn resolve_wasm_definition_tokens_in_context(
&self,
token: u128,
context_tokens: &[DcShorthand],
) -> Option<&[DcShorthand]> { ... }
fn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize> { ... }
fn resolve_named_type_with_arg(
&self,
name: &str,
arg: Option<&SubtypeConstraint>,
) -> Option<SyntaxPattern> { ... }
fn may_match_any_script(&self, _token: u128) -> bool { ... }
fn has_script(&self, _script_name: &str) -> bool { ... }
fn matches_named_type_starter(&self, _name: &str, _token: u128) -> bool { ... }
fn canonical_token(&self, token: u128) -> u128 { ... }
fn unicode_text_mapping(
&self,
_token: u128,
_approximate: bool,
) -> Option<&str> { ... }
fn equivalent_short_dc_for_unicode(
&self,
_tokens: &[u128],
) -> Option<(u128, usize)> { ... }
fn is_equivalent_to(&self, token: u128, canonical: u128) -> bool { ... }
fn token_fills_role(&self, token: u128, role: DcRole) -> bool { ... }
fn base64_digit_value(&self, token: u128) -> Option<u8> { ... }
fn is_representation_set(&self, token: u128) -> bool { ... }
fn is_representation_header_or_separator(&self, token: u128) -> bool { ... }
fn closing_opener_for(&self, _token: u128) -> Option<&CharTarget> { ... }
fn closer_for_opener(&self, _opener: &CharTarget) -> Option<u128> { ... }
fn is_deprecated(&self, _target: &CharTarget) -> bool { ... }
fn preferred_replacement(&self, _target: &CharTarget) -> Option<&CharTarget> { ... }
fn container_header_elements(
&self,
_opener: &CharTarget,
) -> &[SyntaxElement] { ... }
fn trailing_after_closer(&self, _opener: &CharTarget) -> &[SyntaxElement] { ... }
fn resolve_infix_rule(
&self,
_op_token: u128,
) -> Option<(&[SyntaxElement], &[SyntaxElement])> { ... }
fn is_opaque_container(&self, _opener_token: u128) -> bool { ... }
fn is_subtype_of(&self, sub_token: u128, super_token: u128) -> bool { ... }
fn framing_shape(&self, token: u128) -> FramingShape { ... }
fn is_special_wrapper_token(&self, token: u128) -> bool { ... }
fn is_splice_trigger_token(&self, token: u128) -> bool { ... }
fn is_plain_atom_dc(&self, token: u128) -> bool { ... }
fn is_assignment_construct(&self, token: u128) -> bool { ... }
fn token_satisfies_type(
&self,
tok: u128,
req_name: &str,
req_subtype: Option<&SubtypeConstraint>,
) -> bool { ... }
fn resolve_list_element_term(
&self,
subtype: Option<&SubtypeConstraint>,
) -> Option<SyntaxTerm> { ... }
}Expand description
Trait providing resolution of syntax rules, named types, and script sets.
Required Methods§
Sourcefn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>
fn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>
Resolves the syntax rule associated with a character or format target.
Sourcefn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>
fn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>
Resolves the pattern definition for a named syntactic construct.
Sourcefn matches_script(&self, script_name: &str, token: u128) -> bool
fn matches_script(&self, script_name: &str, token: u128) -> bool
Checks whether a character token belongs to a designated script.
Provided Methods§
Sourcefn seed_graph(&self) -> Option<&SeedGraphIndex>
fn seed_graph(&self) -> Option<&SeedGraphIndex>
Returns the underlying SeedGraphIndex when backed by the System-block seed graph.
Sourcefn resolve_rule_tokens(&self, target: &CharTarget) -> Option<&[DcShorthand]>
fn resolve_rule_tokens(&self, target: &CharTarget) -> Option<&[DcShorthand]>
Resolves the raw .Semantic:Pattern token sequence (Dc 594 "Syntax rule") for target
directly from the seed graph without constructing a Rust SyntaxPattern AST.
Sourcefn resolve_named_type_tokens(&self, name: &str) -> Option<&[DcShorthand]>
fn resolve_named_type_tokens(&self, name: &str) -> Option<&[DcShorthand]>
Resolves the raw .Semantic:Pattern token sequence (Dc 594 "Syntax rule") for a named
construct directly from the seed graph without constructing a Rust SyntaxPattern AST.
Sourcefn resolve_wasm_definition_tokens(&self, token: u128) -> Option<&[DcShorthand]>
fn resolve_wasm_definition_tokens(&self, token: u128) -> Option<&[DcShorthand]>
Resolves any active .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.
Sourcefn 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]>
Resolves any active context-scoped (Dc 646 "In context of") .WASM program attached to
token (or its canonical equivalent) matching context_tokens in the seed graph.
Sourcefn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize>
fn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize>
Returns the number of payload elements (excluding ~) in a format’s sequence syntax rule.
Sourcefn 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>
Resolves the pattern definition for a named construct with macro arguments substituted.
Sourcefn may_match_any_script(&self, _token: u128) -> bool
fn may_match_any_script(&self, _token: u128) -> bool
Fast filter returning false when token is known not to belong to any script.
Sourcefn has_script(&self, _script_name: &str) -> bool
fn has_script(&self, _script_name: &str) -> bool
Checks whether a designated script name exists in the dataset.
Sourcefn matches_named_type_starter(&self, _name: &str, _token: u128) -> bool
fn matches_named_type_starter(&self, _name: &str, _token: u128) -> bool
Returns true if token can appear as the leading token of the named construct name.
Sourcefn canonical_token(&self, token: u128) -> u128
fn canonical_token(&self, token: u128) -> u128
Returns the canonical token in this token’s equivalence class,
or token itself if no <equiv> alias is defined.
Sourcefn unicode_text_mapping(&self, _token: u128, _approximate: bool) -> Option<&str>
fn unicode_text_mapping(&self, _token: u128, _approximate: bool) -> Option<&str>
Returns Unicode text derived from declared equivalences and, when requested, approximations. Unresolved or cyclic mappings return None.
Sourcefn equivalent_short_dc_for_unicode(
&self,
_tokens: &[u128],
) -> Option<(u128, usize)>
fn equivalent_short_dc_for_unicode( &self, _tokens: &[u128], ) -> Option<(u128, usize)>
Matches the longest prefix of tokens that has an exact (<equiv>)
mapping from an already-assigned short Dc (< 641), returning
(short_dc_global_id, consumed_token_count).
Sourcefn is_equivalent_to(&self, token: u128, canonical: u128) -> bool
fn is_equivalent_to(&self, token: u128, canonical: u128) -> bool
Checks semantic token equivalence, independently of grammar types.
Sourcefn token_fills_role(&self, token: u128, role: DcRole) -> bool
fn token_fills_role(&self, token: u128, role: DcRole) -> bool
Checks whether token fills the designated syntactic or semantic role.
Sourcefn base64_digit_value(&self, token: u128) -> Option<u8>
fn base64_digit_value(&self, token: u128) -> Option<u8>
Returns the Base64 numeral digit value (0..=63) or padding sentinel (64)
if token (or its canonical equivalent) represents a Base64 encapsulation character.
Sourcefn is_representation_set(&self, token: u128) -> bool
fn is_representation_set(&self, token: u128) -> bool
Classifies full and partial alternative-representation wrappers.
Sourcefn is_representation_header_or_separator(&self, token: u128) -> bool
fn is_representation_header_or_separator(&self, token: u128) -> bool
Classifies list headers and separators in alternative representations.
Sourcefn closing_opener_for(&self, _token: u128) -> Option<&CharTarget>
fn closing_opener_for(&self, _token: u128) -> Option<&CharTarget>
Returns the opener target if this character token is a closing delimiter.
Sourcefn closer_for_opener(&self, _opener: &CharTarget) -> Option<u128>
fn closer_for_opener(&self, _opener: &CharTarget) -> Option<u128>
Returns the closing token for an opener target if known.
Sourcefn is_deprecated(&self, _target: &CharTarget) -> bool
fn is_deprecated(&self, _target: &CharTarget) -> bool
Returns true if the given character or format target is marked deprecated in the dataset.
Sourcefn preferred_replacement(&self, _target: &CharTarget) -> Option<&CharTarget>
fn preferred_replacement(&self, _target: &CharTarget) -> Option<&CharTarget>
Returns the preferred replacement target (<prefer>...) for a deprecated target, if any.
Sourcefn container_header_elements(&self, _opener: &CharTarget) -> &[SyntaxElement]
fn container_header_elements(&self, _opener: &CharTarget) -> &[SyntaxElement]
Returns the leading header syntax elements between ~ and the container body/closer
(for example, [number $length]? [type] for 310, or [format] for 511).
Sourcefn trailing_after_closer(&self, _opener: &CharTarget) -> &[SyntaxElement]
fn trailing_after_closer(&self, _opener: &CharTarget) -> &[SyntaxElement]
Returns any syntax elements required immediately after a container’s closing delimiter
(for example, [545:] after 544 in 543’s rule :~ [^544]+ 544 [545:]).
Sourcefn resolve_infix_rule(
&self,
_op_token: u128,
) -> Option<(&[SyntaxElement], &[SyntaxElement])>
fn resolve_infix_rule( &self, _op_token: u128, ) -> Option<(&[SyntaxElement], &[SyntaxElement])>
Resolves an infix operator rule (lhs_elements, rhs_elements) where ~ is preceded
by a left-hand operand (for example, Dc 269: :[identifier $ident] ~ [value $val]).
Sourcefn is_opaque_container(&self, _opener_token: u128) -> bool
fn is_opaque_container(&self, _opener_token: u128) -> bool
Returns true if the container opened by 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.
Sourcefn is_subtype_of(&self, sub_token: u128, super_token: u128) -> bool
fn is_subtype_of(&self, sub_token: u128, super_token: u128) -> bool
Returns true if sub_token is equivalent to or a transitive subtype (Dc 587) of super_token.
Sourcefn framing_shape(&self, token: u128) -> FramingShape
fn framing_shape(&self, token: u128) -> FramingShape
Returns the physical framing shape classification for token.
Sourcefn is_special_wrapper_token(&self, token: u128) -> bool
fn is_special_wrapper_token(&self, token: u128) -> bool
Returns true if token is a wrapper construct (OptionalPresent,
OptionalAbsent, or is_representation_set) handled transparently by pattern evaluation.
Sourcefn is_splice_trigger_token(&self, token: u128) -> bool
fn is_splice_trigger_token(&self, token: u128) -> bool
Returns true if token emits into the evaluated stream.
Sourcefn is_plain_atom_dc(&self, token: u128) -> bool
fn is_plain_atom_dc(&self, token: u128) -> bool
Returns true if token matches the single-token branch of [atom_dc]
(i.e. is not in the negated delimiter/operator exclusion set of atom_dc).
Sourcefn is_assignment_construct(&self, token: u128) -> bool
fn is_assignment_construct(&self, token: u128) -> bool
Returns true if token is an assignment construct (DcRole::LangAssign, an infix assignment
operator, or a syntax rule whose action is lang.assign).
Sourcefn 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
Checks whether a single type/format token tok satisfies the type requirement (req_name, req_subtype).
Sourcefn resolve_list_element_term(
&self,
subtype: Option<&SubtypeConstraint>,
) -> Option<SyntaxTerm>
fn resolve_list_element_term( &self, subtype: Option<&SubtypeConstraint>, ) -> Option<SyntaxTerm>
Resolves the element SyntaxTerm for a [list:<subtype>] constraint.