public static class SemanticContext.Predicate extends SemanticContext
SemanticContext.AND, SemanticContext.CommutativePredicate, SemanticContext.FalsePredicate, SemanticContext.NOT, SemanticContext.OR, SemanticContext.Predicate, SemanticContext.TruePredicate
Modifier and Type | Field and Description |
---|---|
protected int |
constantValue
sometimes predicates are known to be true or false; we need
a way to represent this without resorting to a target language
value like true or TRUE.
|
static int |
FALSE_PRED |
protected boolean |
gated
Is this a {...}?=> gating predicate or a normal disambiguating {..}?
If any predicate in expression is gated, then expression is considered
gated.
|
static int |
INVALID_PRED_VALUE |
GrammarAST |
predicateAST
The AST node in tree created from the grammar holding the predicate
|
protected boolean |
synpred
syntactic predicates are converted to semantic predicates
but synpreds are generated slightly differently.
|
static int |
TRUE_PRED |
EMPTY_SEMANTIC_CONTEXT
Constructor and Description |
---|
Predicate(GrammarAST predicate) |
Predicate(int constantValue) |
Predicate(SemanticContext.Predicate p) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Two predicates are the same if they are literally the same
text rather than same node in the grammar's AST.
|
org.stringtemplate.v4.ST |
genExpr(CodeGenerator generator,
org.stringtemplate.v4.STGroup templates,
DFA dfa)
Generate an expression that will evaluate the semantic context,
given a set of output templates.
|
SemanticContext |
getGatedPredicateContext()
Given a semantic context expression tree, return a tree with all
nongated predicates set to true and then reduced.
|
int |
hashCode() |
boolean |
hasUserSemanticPredicate() |
boolean |
isSyntacticPredicate() |
String |
toString() |
void |
trackUseOfSyntacticPredicates(Grammar g)
Notify the indicated grammar of any syn preds used within this context
|
and, factorAnd, factorOr, getAndOperands, getOrOperands, not, or
public GrammarAST predicateAST
protected boolean gated
protected boolean synpred
public static final int INVALID_PRED_VALUE
public static final int FALSE_PRED
public static final int TRUE_PRED
protected int constantValue
public Predicate(int constantValue)
public Predicate(GrammarAST predicate)
public Predicate(SemanticContext.Predicate p)
public boolean equals(Object o)
public org.stringtemplate.v4.ST genExpr(CodeGenerator generator, org.stringtemplate.v4.STGroup templates, DFA dfa)
SemanticContext
genExpr
in class SemanticContext
public SemanticContext getGatedPredicateContext()
SemanticContext
getGatedPredicateContext
in class SemanticContext
public boolean hasUserSemanticPredicate()
hasUserSemanticPredicate
in class SemanticContext
public boolean isSyntacticPredicate()
isSyntacticPredicate
in class SemanticContext
public void trackUseOfSyntacticPredicates(Grammar g)
SemanticContext
trackUseOfSyntacticPredicates
in class SemanticContext
Copyright © 1992–2015 ANTLR. All rights reserved.