public abstract class SemanticContext
extends java.lang.Object
p1&&p2
, or a sum of products p1||p2
.
I have scoped the SemanticContext.AND
, SemanticContext.OR
, and SemanticContext.Predicate
subclasses of
SemanticContext
within the scope of this outer class.
Modifier and Type | Class and Description |
---|---|
static class |
SemanticContext.AND
A semantic context which is true whenever none of the contained contexts
is false.
|
static class |
SemanticContext.Operator
This is the base class for semantic context "operators", which operate on
a collection of semantic context "operands".
|
static class |
SemanticContext.OR
A semantic context which is true whenever at least one of the contained
contexts is true.
|
static class |
SemanticContext.PrecedencePredicate |
static class |
SemanticContext.Predicate |
Modifier and Type | Field and Description |
---|---|
static SemanticContext |
NONE
The default
SemanticContext , which is semantically equivalent to
a predicate of the form {true}? . |
Constructor and Description |
---|
SemanticContext() |
Modifier and Type | Method and Description |
---|---|
static SemanticContext |
and(SemanticContext a,
SemanticContext b) |
abstract boolean |
eval(Recognizer<?,?> parser,
RuleContext parserCallStack)
For context independent predicates, we evaluate them without a local
context (i.e., null context).
|
SemanticContext |
evalPrecedence(Recognizer<?,?> parser,
RuleContext parserCallStack)
Evaluate the precedence predicates for the context and reduce the result.
|
static SemanticContext |
or(SemanticContext a,
SemanticContext b) |
public static final SemanticContext NONE
SemanticContext
, which is semantically equivalent to
a predicate of the form {true}?
.public abstract boolean eval(Recognizer<?,?> parser, RuleContext parserCallStack)
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.
public SemanticContext evalPrecedence(Recognizer<?,?> parser, RuleContext parserCallStack)
parser
- The parser instance.parserCallStack
- NONE
: if the predicate simplifies to true
after
precedence predicates are evaluated.null
: if the predicate simplifies to false
after
precedence predicates are evaluated.this
: if the semantic context is not changed as a result of
precedence predicate evaluation.null
SemanticContext
: the new simplified
semantic context after precedence predicates are evaluated.public static SemanticContext and(SemanticContext a, SemanticContext b)
public static SemanticContext or(SemanticContext a, SemanticContext b)