SyntaxRuleResolver

Trait SyntaxRuleResolver 

Source
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§

Source

fn resolve_rule(&self, target: &CharTarget) -> Option<&DcSyntaxRule>

Resolves the syntax rule associated with a character or format target.

Source

fn resolve_named_type(&self, name: &str) -> Option<&SyntaxPattern>

Resolves the pattern definition for a named syntactic construct.

Source

fn matches_script(&self, script_name: &str, token: u128) -> bool

Checks whether a character token belongs to a designated script.

Provided Methods§

Source

fn seed_graph(&self) -> Option<&SeedGraphIndex>

Returns the underlying SeedGraphIndex when backed by the System-block seed graph.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn format_rule_payload_arity(&self, fid: FormatId) -> Option<usize>

Returns the number of payload elements (excluding ~) in a format’s sequence syntax rule.

Source

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.

Source

fn may_match_any_script(&self, _token: u128) -> bool

Fast filter returning false when token is known not to belong to any script.

Source

fn has_script(&self, _script_name: &str) -> bool

Checks whether a designated script name exists in the dataset.

Source

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.

Source

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.

Source

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.

Source

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).

Source

fn is_equivalent_to(&self, token: u128, canonical: u128) -> bool

Checks semantic token equivalence, independently of grammar types.

Source

fn token_fills_role(&self, token: u128, role: DcRole) -> bool

Checks whether token fills the designated syntactic or semantic role.

Source

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.

Source

fn is_representation_set(&self, token: u128) -> bool

Classifies full and partial alternative-representation wrappers.

Source

fn is_representation_header_or_separator(&self, token: u128) -> bool

Classifies list headers and separators in alternative representations.

Source

fn closing_opener_for(&self, _token: u128) -> Option<&CharTarget>

Returns the opener target if this character token is a closing delimiter.

Source

fn closer_for_opener(&self, _opener: &CharTarget) -> Option<u128>

Returns the closing token for an opener target if known.

Source

fn is_deprecated(&self, _target: &CharTarget) -> bool

Returns true if the given character or format target is marked deprecated in the dataset.

Source

fn preferred_replacement(&self, _target: &CharTarget) -> Option<&CharTarget>

Returns the preferred replacement target (<prefer>...) for a deprecated target, if any.

Source

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).

Source

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:]).

Source

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]).

Source

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.

Source

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.

Source

fn framing_shape(&self, token: u128) -> FramingShape

Returns the physical framing shape classification for token.

Source

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.

Source

fn is_splice_trigger_token(&self, token: u128) -> bool

Returns true if token emits into the evaluated stream.

Source

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).

Source

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).

Source

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).

Source

fn resolve_list_element_term( &self, subtype: Option<&SubtypeConstraint>, ) -> Option<SyntaxTerm>

Resolves the element SyntaxTerm for a [list:<subtype>] constraint.

Implementors§