Trait teleparse::AbstractSyntaxTree
source · pub trait AbstractSyntaxTree: Sized + ToSpan + 'static {
type L: Lexicon + 'static;
// Required methods
fn build_first(builder: &mut FirstBuilder<Self::L>);
fn check_left_recursive(
seen: &mut BTreeSet<TypeId>,
stack: &mut Vec<String>,
set: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
) -> Result<(), GrammarError>;
fn check_first_conflict(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
) -> Result<(), GrammarError>;
fn build_follow(builder: &mut FollowBuilder<Self::L>);
fn check_first_follow_conflict(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
follow: &Follow<Self::L>,
) -> Result<(), GrammarError>;
fn build_jump(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
jump: &mut Jump<Self::L>,
);
fn parse_ast<'s>(
parser: &mut Parser<'s, Self::L>,
meta: &Metadata<Self::L>,
) -> Result<Self, Self::L>;
// Provided methods
fn type_id() -> TypeId { ... }
fn debug() -> Cow<'static, str> { ... }
fn check_self_first_follow_conflict(
first: &First<Self::L>,
follow: &Follow<Self::L>,
) -> Result<(), GrammarError> { ... }
}Expand description
An AST node
See module-level documentation for more information.
Required Associated Types§
Required Methods§
sourcefn build_first(builder: &mut FirstBuilder<Self::L>)
fn build_first(builder: &mut FirstBuilder<Self::L>)
Add the rules for this AST node (recursively) to the FIRST function builder.
Note this may not terminate if the grammar is left-recursive
sourcefn check_left_recursive(
seen: &mut BTreeSet<TypeId>,
stack: &mut Vec<String>,
set: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
) -> Result<(), GrammarError>
fn check_left_recursive( seen: &mut BTreeSet<TypeId>, stack: &mut Vec<String>, set: &mut BTreeSet<TypeId>, first: &First<Self::L>, ) -> Result<(), GrammarError>
Check if the grammar at this AST node is left-recursive
Left-recursion will lead to infinite recursion when parsing, so it is not allowed
sourcefn check_first_conflict(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
) -> Result<(), GrammarError>
fn check_first_conflict( seen: &mut BTreeSet<TypeId>, first: &First<Self::L>, ) -> Result<(), GrammarError>
Check for conflicts in the FIRST set of this AST node
sourcefn build_follow(builder: &mut FollowBuilder<Self::L>)
fn build_follow(builder: &mut FollowBuilder<Self::L>)
Add the rules for this AST node (recursively) to the FOLLOW function builder.
sourcefn check_first_follow_conflict(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
follow: &Follow<Self::L>,
) -> Result<(), GrammarError>
fn check_first_follow_conflict( seen: &mut BTreeSet<TypeId>, first: &First<Self::L>, follow: &Follow<Self::L>, ) -> Result<(), GrammarError>
Check for conflicts in the FIRST and FOLLOW set of this AST node recursively
sourcefn build_jump(
seen: &mut BTreeSet<TypeId>,
first: &First<Self::L>,
jump: &mut Jump<Self::L>,
)
fn build_jump( seen: &mut BTreeSet<TypeId>, first: &First<Self::L>, jump: &mut Jump<Self::L>, )
Recursively build the parsing table for this AST node.
See Predictive parsing table for more information.
Provided Methods§
sourcefn type_id() -> TypeId
fn type_id() -> TypeId
Get the unique type id of the AST node, which represents one production in the grammar (multiple production in case of a union/enum)
sourcefn check_self_first_follow_conflict(
first: &First<Self::L>,
follow: &Follow<Self::L>,
) -> Result<(), GrammarError>
fn check_self_first_follow_conflict( first: &First<Self::L>, follow: &Follow<Self::L>, ) -> Result<(), GrammarError>
Check if epsilon is in FIRST(t) and FIRST(t) intersect FOLLOW(t)
This is used in derived AST implementations to check for conflicts