Package org.antlr.v4.runtime.atn
Class SemanticContext.AND
- java.lang.Object
-
- org.antlr.v4.runtime.atn.SemanticContext
-
- org.antlr.v4.runtime.atn.SemanticContext.Operator
-
- org.antlr.v4.runtime.atn.SemanticContext.AND
-
- Enclosing class:
- SemanticContext
public static class SemanticContext.AND extends SemanticContext.Operator
A semantic context which is true whenever none of the contained contexts is false.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.antlr.v4.runtime.atn.SemanticContext
SemanticContext.AND, SemanticContext.Empty, SemanticContext.Operator, SemanticContext.OR, SemanticContext.PrecedencePredicate, SemanticContext.Predicate
-
-
Field Summary
Fields Modifier and Type Field Description SemanticContext[]opnds
-
Constructor Summary
Constructors Constructor Description AND(SemanticContext a, SemanticContext b)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)booleaneval(Recognizer<?,?> parser, RuleContext parserCallStack)For context independent predicates, we evaluate them without a local context (i.e., null context).SemanticContextevalPrecedence(Recognizer<?,?> parser, RuleContext parserCallStack)Evaluate the precedence predicates for the context and reduce the result.Collection<SemanticContext>getOperands()Gets the operands for the semantic context operator.inthashCode()StringtoString()-
Methods inherited from class org.antlr.v4.runtime.atn.SemanticContext
and, or
-
-
-
-
Field Detail
-
opnds
public final SemanticContext[] opnds
-
-
Constructor Detail
-
AND
public AND(SemanticContext a, SemanticContext b)
-
-
Method Detail
-
getOperands
public Collection<SemanticContext> getOperands()
Description copied from class:SemanticContext.OperatorGets the operands for the semantic context operator.- Specified by:
getOperandsin classSemanticContext.Operator- Returns:
- a collection of
SemanticContextoperands for the operator.
-
eval
public boolean eval(Recognizer<?,?> parser, RuleContext parserCallStack)
For 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.
The evaluation of predicates by this context is short-circuiting, but unordered.
- Specified by:
evalin classSemanticContext
-
evalPrecedence
public SemanticContext evalPrecedence(Recognizer<?,?> parser, RuleContext parserCallStack)
Description copied from class:SemanticContextEvaluate the precedence predicates for the context and reduce the result.- Overrides:
evalPrecedencein classSemanticContext- Parameters:
parser- The parser instance.- 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.
-
-