@Override public SemanticContext combinePredicates(SemanticContext left, SemanticContext right) { return SemanticContext.and(left, right); }
public SemanticContext getGatedPredicateContext() { SemanticContext gatedLeft = left.getGatedPredicateContext(); SemanticContext gatedRight = right.getGatedPredicateContext(); if ( gatedLeft==null ) { return gatedRight; } if ( gatedRight==null ) { return gatedLeft; } return new AND(gatedLeft, gatedRight); } public boolean isSyntacticPredicate() {
@Override public boolean isSyntacticPredicate() { for (SemanticContext semctx : operands) { if ( semctx.isSyntacticPredicate() ) { return true; } } return false; }
public static Collection<SemanticContext> getAndOperands(SemanticContext context) { if (context instanceof AND) return ((AND)context).operands; if (context instanceof NOT) { Collection<SemanticContext> operands = getOrOperands(((NOT)context).ctx); List<SemanticContext> result = new ArrayList<SemanticContext>(operands.size()); for (SemanticContext operand : operands) { result.add(not(operand)); } return result; } ArrayList<SemanticContext> result = new ArrayList<SemanticContext>(); result.add(context); return result; }
public static Collection<SemanticContext> getOrOperands(SemanticContext context) { if (context instanceof OR) return ((OR)context).operands; if (context instanceof NOT) { Collection<SemanticContext> operands = getAndOperands(((NOT)context).ctx); List<SemanticContext> result = new ArrayList<SemanticContext>(operands.size()); for (SemanticContext operand : operands) { result.add(not(operand)); } return result; } ArrayList<SemanticContext> result = new ArrayList<SemanticContext>(); result.add(context); return result; } }
NFAConfiguration configuration = nfaConfigurations.get(i); SemanticContext gatedPredExpr = configuration.semanticContext.getGatedPredicateContext(); if ( gatedPredExpr==null ) { else if ( acceptState || !configuration.semanticContext.isSyntacticPredicate() ) { SemanticContext.or(unionOfPredicatesFromAllAlts,gatedPredExpr);
protected StringTemplate genSemanticPredicateExpr(StringTemplateGroup templates, Transition edge) { DFA dfa = ((DFAState)edge.target).dfa; // which DFA are we in Label label = edge.label; SemanticContext semCtx = label.getSemanticContext(); return semCtx.genExpr(this,templates,dfa); }
public Set<? extends SemanticContext> getGatedSyntacticPredicatesInNFAConfigurations() { int numConfigs = nfaConfigurations.size(); Set<SemanticContext> synpreds = new HashSet<SemanticContext>(); for (int i = 0; i < numConfigs; i++) { NFAConfiguration configuration = nfaConfigurations.get(i); SemanticContext gatedPredExpr = configuration.semanticContext.getGatedPredicateContext(); // if this is a manual syn pred (gated and syn pred), add if ( gatedPredExpr!=null && configuration.semanticContext.isSyntacticPredicate() ) { synpreds.add(configuration.semanticContext); } } if ( synpreds.isEmpty() ) { return null; } return synpreds; }
getUnionOfPredicates(altToPredMap); if ( unionOfPredicatesFromAllAlts.isSyntacticPredicate() ) { nakedAltPred = new SemanticContext.TruePredicate(); SemanticContext.not(unionOfPredicatesFromAllAlts); if ( semCtx.isSyntacticPredicate() ) { dfa.nfa.grammar.synPredUsedInDFA(dfa, semCtx);
if ( !labelContext.isSyntacticPredicate() || p==altLeftEdge.transition[0].target ) SemanticContext.and(semanticContext, labelContext);
@Override public void trackUseOfSyntacticPredicates(Grammar g) { for (SemanticContext semctx : operands) { semctx.trackUseOfSyntacticPredicates(g); } }
return new TruePredicate(); SemanticContext[] terms = factorAnd(a, b); SemanticContext commonTerms = terms[0]; a = terms[1]; boolean factored = commonTerms != null && commonTerms != EMPTY_SEMANTIC_CONTEXT && !(commonTerms instanceof FalsePredicate); if (factored) { return and(commonTerms, or(a, b));
@Override public SemanticContext combinePredicates(SemanticContext left, SemanticContext right) { return SemanticContext.or(left, right); }
@Override public boolean hasUserSemanticPredicate() { for (SemanticContext semctx : operands) { if ( semctx.hasUserSemanticPredicate() ) { return true; } } return false; }
NFAConfiguration configuration = (NFAConfiguration) nfaConfigurations.get(i); SemanticContext gatedPredExpr = configuration.semanticContext.getGatedPredicateContext(); if ( gatedPredExpr==null ) { else if ( acceptState || !configuration.semanticContext.isSyntacticPredicate() ) { SemanticContext.or(unionOfPredicatesFromAllAlts,gatedPredExpr);
protected StringTemplate genSemanticPredicateExpr(StringTemplateGroup templates, Transition edge) { DFA dfa = ((DFAState)edge.target).dfa; // which DFA are we in Label label = edge.label; SemanticContext semCtx = label.getSemanticContext(); return semCtx.genExpr(this,templates,dfa); }
public Set<? extends SemanticContext> getGatedSyntacticPredicatesInNFAConfigurations() { int numConfigs = nfaConfigurations.size(); Set<SemanticContext> synpreds = new HashSet<SemanticContext>(); for (int i = 0; i < numConfigs; i++) { NFAConfiguration configuration = nfaConfigurations.get(i); SemanticContext gatedPredExpr = configuration.semanticContext.getGatedPredicateContext(); // if this is a manual syn pred (gated and syn pred), add if ( gatedPredExpr!=null && configuration.semanticContext.isSyntacticPredicate() ) { synpreds.add(configuration.semanticContext); } } if ( synpreds.isEmpty() ) { return null; } return synpreds; }