Class SemanticContext.PrecedencePredicate
java.lang.Object
org.graalvm.shadowed.org.antlr.v4.runtime.atn.SemanticContext
org.graalvm.shadowed.org.antlr.v4.runtime.atn.SemanticContext.PrecedencePredicate
- All Implemented Interfaces:
Comparable<SemanticContext.PrecedencePredicate>
- Enclosing class:
SemanticContext
public static class SemanticContext.PrecedencePredicate
extends SemanticContext
implements Comparable<SemanticContext.PrecedencePredicate>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.graalvm.shadowed.org.antlr.v4.runtime.atn.SemanticContext
SemanticContext.AND, SemanticContext.Empty, SemanticContext.Operator, SemanticContext.OR, SemanticContext.PrecedencePredicate, SemanticContext.Predicate -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanbooleaneval(Recognizer<?, ?> parser, RuleContext parserCallStack) For context independent predicates, we evaluate them without a local context (i.e., null context).evalPrecedence(Recognizer<?, ?> parser, RuleContext parserCallStack) Evaluate the precedence predicates for the context and reduce the result.inthashCode()toString()Methods inherited from class org.graalvm.shadowed.org.antlr.v4.runtime.atn.SemanticContext
and, or
-
Field Details
-
precedence
public final int precedence
-
-
Constructor Details
-
PrecedencePredicate
protected PrecedencePredicate() -
PrecedencePredicate
public PrecedencePredicate(int precedence)
-
-
Method Details
-
eval
Description copied from class:SemanticContextFor context independent predicates, we evaluate them without a local context (i.e., null context). That way, we can evaluate them without having to create proper rule-specific context during prediction (as opposed to the parser, which creates them naturally). In a practical sense, this avoids a cast exception from RuleContext to myruleContext.For context dependent predicates, we must pass in a local context so that references such as $arg evaluate properly as _localctx.arg. We only capture context dependent predicates in the context in which we begin prediction, so we passed in the outer context here in case of context dependent predicate evaluation.
- Specified by:
evalin classSemanticContext
-
evalPrecedence
Description copied from class:SemanticContextEvaluate the precedence predicates for the context and reduce the result.- Overrides:
evalPrecedencein classSemanticContext- Parameters:
parser- The parser instance.parserCallStack-- Returns:
- The simplified semantic context after precedence predicates are
evaluated, which will be one of the following values.
SemanticContext.Empty.Instance: if the predicate simplifies totrueafter precedence predicates are evaluated.null: if the predicate simplifies tofalseafter precedence predicates are evaluated.this: if the semantic context is not changed as a result of precedence predicate evaluation.- A non-
nullSemanticContext: the new simplified semantic context after precedence predicates are evaluated.
-
compareTo
- Specified by:
compareToin interfaceComparable<SemanticContext.PrecedencePredicate>
-
hashCode
-
equals
-
toString
-