pub enum ParserPredicate {
True,
False,
FalseWithMessage {
message: &'static str,
},
Invoke {
value: bool,
},
LookaheadTextEquals {
offset: isize,
text: &'static str,
},
LookaheadNotEquals {
offset: isize,
token_type: i32,
},
TokenPairAdjacent,
ContextChildRuleTextNotEquals {
rule_index: usize,
text: &'static str,
},
LocalIntEquals {
value: i64,
},
LocalIntLessOrEqual {
value: i64,
},
MemberModuloEquals {
member: usize,
modulus: i64,
value: i64,
equals: bool,
},
MemberEquals {
member: usize,
value: i64,
equals: bool,
},
}Expand description
Parser semantic predicate rendered from a supported target template.
The metadata recognizer evaluates these at the token-stream index where the predicate transition is reached. Unsupported or absent predicate templates remain unconditional so existing generated parsers keep their previous behavior unless the generator opts into this table.
Variants§
True
False
FalseWithMessage
Predicate that always fails and carries ANTLR’s <fail='...'> message.
Invoke
Target-template test helper that reports predicate evaluation before returning the wrapped boolean value.
LookaheadTextEquals
LookaheadNotEquals
TokenPairAdjacent
Checks that the last two consumed visible tokens were adjacent in the token stream. Used by C# parser predicates for split operator tokens.
ContextChildRuleTextNotEquals
Checks a generated parser context child by rule index and text.
If the child is absent the predicate succeeds, matching target helpers that treat incomplete or non-matching contexts as non-restrictive.
LocalIntEquals
Compares the current rule invocation’s integer argument with a literal
value from a supported ValEquals("$i", "...") target template.
LocalIntLessOrEqual
Checks ANTLR-style raw predicates like 5 >= $_p against the current
rule invocation’s integer argument.
MemberModuloEquals
Compares a generated parser integer member modulo a literal value.
MemberEquals
Compares a generated parser integer member with a literal value.
Implementations§
Source§impl ParserPredicate
impl ParserPredicate
Sourcepub fn lower_into_semir(self, ir: &mut SemIr) -> ExprId
pub fn lower_into_semir(self, ir: &mut SemIr) -> ExprId
Lowers the legacy predicate metadata variant into SemIR.
This is the compatibility adapter for generated parsers produced while
the runtime still emitted closed enum tables. Newer generated parsers
emit SemIR directly.
pub const fn failure_message(self) -> Option<&'static str>
Trait Implementations§
Source§impl Clone for ParserPredicate
impl Clone for ParserPredicate
Source§fn clone(&self) -> ParserPredicate
fn clone(&self) -> ParserPredicate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more