org.antlr.analysis
Class SemanticContext.Predicate

java.lang.Object
  extended by org.antlr.analysis.SemanticContext
      extended by org.antlr.analysis.SemanticContext.Predicate
Direct Known Subclasses:
SemanticContext.TruePredicate
Enclosing class:
SemanticContext

public static class SemanticContext.Predicate
extends SemanticContext


Nested Class Summary
 
Nested classes/interfaces inherited from class org.antlr.analysis.SemanticContext
SemanticContext.AND, SemanticContext.NOT, SemanticContext.OR, SemanticContext.Predicate, SemanticContext.TruePredicate
 
Field Summary
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
           
 
Fields inherited from class org.antlr.analysis.SemanticContext
EMPTY_SEMANTIC_CONTEXT
 
Constructor Summary
SemanticContext.Predicate()
           
SemanticContext.Predicate(GrammarAST predicate)
           
SemanticContext.Predicate(SemanticContext.Predicate p)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Two predicates are the same if they are literally the same text rather than same node in the grammar's AST.
 StringTemplate genExpr(CodeGenerator generator, StringTemplateGroup 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 isSyntacticPredicate()
           
 java.lang.String toString()
           
 void trackUseOfSyntacticPredicates(Grammar g)
          Notify the indicated grammar of any syn preds used within this context
 
Methods inherited from class org.antlr.analysis.SemanticContext
and, not, or
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

predicateAST

public GrammarAST predicateAST
The AST node in tree created from the grammar holding the predicate


gated

protected boolean gated
Is 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 synpred
syntactic predicates are converted to semantic predicates but synpreds are generated slightly differently.


INVALID_PRED_VALUE

public static final int INVALID_PRED_VALUE
See Also:
Constant Field Values

FALSE_PRED

public static final int FALSE_PRED
See Also:
Constant Field Values

TRUE_PRED

public static final int TRUE_PRED
See Also:
Constant Field Values

constantValue

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.

Constructor Detail

SemanticContext.Predicate

public SemanticContext.Predicate()

SemanticContext.Predicate

public SemanticContext.Predicate(GrammarAST predicate)

SemanticContext.Predicate

public SemanticContext.Predicate(SemanticContext.Predicate p)
Method Detail

equals

public boolean equals(java.lang.Object o)
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.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

genExpr

public StringTemplate genExpr(CodeGenerator generator,
                              StringTemplateGroup templates,
                              DFA dfa)
Description copied from class: SemanticContext
Generate an expression that will evaluate the semantic context, given a set of output templates.

Specified by:
genExpr in class SemanticContext

getGatedPredicateContext

public SemanticContext getGatedPredicateContext()
Description copied from class: SemanticContext
Given 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:
getGatedPredicateContext in class SemanticContext

isSyntacticPredicate

public boolean isSyntacticPredicate()
Specified by:
isSyntacticPredicate in class SemanticContext

trackUseOfSyntacticPredicates

public void trackUseOfSyntacticPredicates(Grammar g)
Description copied from class: SemanticContext
Notify the indicated grammar of any syn preds used within this context

Overrides:
trackUseOfSyntacticPredicates in class SemanticContext

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object