Package org.antlr.analysis
Class SemanticContext.Predicate
java.lang.Object
org.antlr.analysis.SemanticContext
org.antlr.analysis.SemanticContext.Predicate
- Direct Known Subclasses:
SemanticContext.FalsePredicate,SemanticContext.TruePredicate
- Enclosing class:
SemanticContext
-
Nested Class Summary
Nested classes/interfaces inherited from class org.antlr.analysis.SemanticContext
SemanticContext.AND, SemanticContext.CommutativePredicate, SemanticContext.FalsePredicate, SemanticContext.NOT, SemanticContext.OR, SemanticContext.Predicate, SemanticContext.TruePredicate -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intsometimes 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 final intprotected booleanIs this a {...}?=> gating predicate or a normal disambiguating {..}? If any predicate in expression is gated, then expression is considered gated.static final intThe AST node in tree created from the grammar holding the predicateprotected booleansyntactic predicates are converted to semantic predicates but synpreds are generated slightly differently.static final intFields inherited from class org.antlr.analysis.SemanticContext
EMPTY_SEMANTIC_CONTEXT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo predicates are the same if they are literally the same text rather than same node in the grammar's AST.org.stringtemplate.v4.STgenExpr(CodeGenerator generator, org.stringtemplate.v4.STGroup templates, DFA dfa) Generate an expression that will evaluate the semantic context, given a set of output templates.Given a semantic context expression tree, return a tree with all nongated predicates set to true and then reduced.inthashCode()booleanbooleantoString()voidNotify the indicated grammar of any syn preds used within this contextMethods inherited from class org.antlr.analysis.SemanticContext
and, factorAnd, factorOr, getAndOperands, getOrOperands, not, or
-
Field Details
-
predicateAST
The AST node in tree created from the grammar holding the predicate -
gated
protected boolean gatedIs this a {...}?=> gating predicate or a normal disambiguating {..}? If any predicate in expression is gated, then expression is considered gated. The simple Predicate object's predicate AST's type is used to set gated to true if type==GATED_SEMPRED. -
synpred
protected boolean synpredsyntactic predicates are converted to semantic predicates but synpreds are generated slightly differently. -
INVALID_PRED_VALUE
public static final int INVALID_PRED_VALUE- See Also:
-
FALSE_PRED
public static final int FALSE_PRED- See Also:
-
TRUE_PRED
public static final int TRUE_PRED- See Also:
-
constantValue
protected int constantValuesometimes 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.
-
-
Constructor Details
-
Predicate
public Predicate(int constantValue) -
Predicate
-
Predicate
-
-
Method Details
-
equals
Two predicates are the same if they are literally the same text rather than same node in the grammar's AST. Or, if they have the same constant value, return equal. As of July 2006 I'm not sure these are needed. -
hashCode
public int hashCode() -
genExpr
public org.stringtemplate.v4.ST genExpr(CodeGenerator generator, org.stringtemplate.v4.STGroup templates, DFA dfa) Description copied from class:SemanticContextGenerate an expression that will evaluate the semantic context, given a set of output templates.- Specified by:
genExprin classSemanticContext
-
getGatedPredicateContext
Description copied from class:SemanticContextGiven a semantic context expression tree, return a tree with all nongated predicates set to true and then reduced. So p&&(q||r) would return p&&r if q is nongated but p and r are gated.- Specified by:
getGatedPredicateContextin classSemanticContext
-
hasUserSemanticPredicate
public boolean hasUserSemanticPredicate()- Specified by:
hasUserSemanticPredicatein classSemanticContext
-
isSyntacticPredicate
public boolean isSyntacticPredicate()- Specified by:
isSyntacticPredicatein classSemanticContext
-
trackUseOfSyntacticPredicates
Description copied from class:SemanticContextNotify the indicated grammar of any syn preds used within this context- Overrides:
trackUseOfSyntacticPredicatesin classSemanticContext
-
toString
-