类 SemanticContext
- java.lang.Object
-
- org.antlr.analysis.SemanticContext
-
public abstract class SemanticContext extends java.lang.ObjectA binary tree structure used to record the semantic context in which an NFA configuration is valid. It's either a single predicate or a tree representing an operation tree such as: p1&&p2 or p1||p2. For NFA o-p1->o-p2->o, create tree AND(p1,p2). For NFA (1)-p1->(2) | ^ | | (3)-p2---- we will have to combine p1 and p2 into DFA state as we will be adding NFA configurations for state 2 with two predicates p1,p2. So, set context for combined NFA config for state 2: OR(p1,p2). I have scoped the AND, NOT, OR, and Predicate subclasses of SemanticContext within the scope of this outer class. July 7, 2006: TJP altered OR to be set of operands. the Binary tree made it really hard to reduce complicated || sequences to their minimum. Got huge repeated || conditions.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classSemanticContext.ANDstatic classSemanticContext.CommutativePredicatestatic classSemanticContext.FalsePredicatestatic classSemanticContext.NOTstatic classSemanticContext.ORstatic classSemanticContext.Predicatestatic classSemanticContext.TruePredicate
-
字段概要
字段 修饰符和类型 字段 说明 static SemanticContextEMPTY_SEMANTIC_CONTEXTCreate a default value for the semantic context shared among all NFAConfigurations that do not have an actual semantic context.
-
构造器概要
构造器 构造器 说明 SemanticContext()
-
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 static SemanticContextand(SemanticContext a, SemanticContext b)static SemanticContext[]factorAnd(SemanticContext a, SemanticContext b)static SemanticContext[]factorOr(SemanticContext a, SemanticContext b)abstract 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.static java.util.Collection<SemanticContext>getAndOperands(SemanticContext context)abstract SemanticContextgetGatedPredicateContext()Given a semantic context expression tree, return a tree with all nongated predicates set to true and then reduced.static java.util.Collection<SemanticContext>getOrOperands(SemanticContext context)abstract booleanhasUserSemanticPredicate()abstract booleanisSyntacticPredicate()static SemanticContextnot(SemanticContext a)static SemanticContextor(SemanticContext a, SemanticContext b)voidtrackUseOfSyntacticPredicates(Grammar g)Notify the indicated grammar of any syn preds used within this context
-
-
-
字段详细资料
-
EMPTY_SEMANTIC_CONTEXT
public static final SemanticContext EMPTY_SEMANTIC_CONTEXT
Create a default value for the semantic context shared among all NFAConfigurations that do not have an actual semantic context. This prevents lots of if!=null type checks all over; it represents just an empty set of predicates.
-
-
方法详细资料
-
getGatedPredicateContext
public abstract SemanticContext getGatedPredicateContext()
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.
-
genExpr
public abstract 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.
-
hasUserSemanticPredicate
public abstract boolean hasUserSemanticPredicate()
-
isSyntacticPredicate
public abstract boolean isSyntacticPredicate()
-
trackUseOfSyntacticPredicates
public void trackUseOfSyntacticPredicates(Grammar g)
Notify the indicated grammar of any syn preds used within this context
-
and
public static SemanticContext and(SemanticContext a, SemanticContext b)
-
or
public static SemanticContext or(SemanticContext a, SemanticContext b)
-
not
public static SemanticContext not(SemanticContext a)
-
factorAnd
public static SemanticContext[] factorAnd(SemanticContext a, SemanticContext b)
-
factorOr
public static SemanticContext[] factorOr(SemanticContext a, SemanticContext b)
-
getAndOperands
public static java.util.Collection<SemanticContext> getAndOperands(SemanticContext context)
-
getOrOperands
public static java.util.Collection<SemanticContext> getOrOperands(SemanticContext context)
-
-