public static SemanticContext not(SemanticContext a) { if (a instanceof NOT) { return ((NOT)a).ctx; } if (a instanceof TruePredicate) return new FalsePredicate(); else if (a instanceof FalsePredicate) return new TruePredicate(); return new NOT(a); }
public NFAState newState() { NFAState n = new NFAState(nfa); int state = nfa.getNewNFAStateNumber(); n.stateNumber = state; nfa.addState(n); n.enclosingRule = currentRule; return n; }
/** Return a string like "3:22: ( A {;} | B )" that describes this * decision. */ public String getDescription() { return dfa.getNFADecisionStartState().getDescription(); }
public boolean canInlineDecision() { return !isCyclic() && !probe.isNonLLStarDecision() && getNumberOfStates() < CodeGenerator.MAX_ACYCLIC_DFA_STATES_INLINE; }
public NFAToDFAConverter(DFA dfa) { this.dfa = dfa; int nAlts = dfa.getNumberOfAlts(); initContextTrees(nAlts); }
private void transitionBetweenStates(NFAState a, NFAState b, int label) { Transition e = new Transition(label,b); a.addTransition(e); } }
/** Resolve state d by choosing exit alt, which is same value as the * number of alternatives. Return that exit alt. */ protected int resolveByPickingExitAlt(DFAState d, Set<Integer> nondeterministicAlts) { int exitAlt = dfa.getNumberOfAlts(); turnOffOtherAlts(d, exitAlt, nondeterministicAlts); return exitAlt; }
public NFAConfiguration addNFAConfiguration(NFAState state, int alt, NFAContext context, SemanticContext semanticContext) { NFAConfiguration c = new NFAConfiguration(state.stateNumber, alt, context, semanticContext); addNFAConfiguration(state, c); return c; }
protected ST genSemanticPredicateExpr(STGroup 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); }
@Override public SemanticContext getGatedPredicateContext() { SemanticContext result = null; for (SemanticContext semctx : operands) { SemanticContext gatedPred = semctx.getGatedPredicateContext(); if ( gatedPred!=null ) { result = combinePredicates(result, gatedPred); } } return result; }
public NFAState newState() { NFAState n = new NFAState(nfa); int state = nfa.getNewNFAStateNumber(); n.stateNumber = state; nfa.addState(n); n.enclosingRule = currentRule; return n; }
/** Return a string like "3:22: ( A {;} | B )" that describes this * decision. */ public String getDescription() { return dfa.getNFADecisionStartState().getDescription(); }
public static SemanticContext not(SemanticContext a) { if (a instanceof NOT) { return ((NOT)a).ctx; } if (a instanceof TruePredicate) return new FalsePredicate(); else if (a instanceof FalsePredicate) return new TruePredicate(); return new NOT(a); }
public NFAToDFAConverter(DFA dfa) { this.dfa = dfa; int nAlts = dfa.getNumberOfAlts(); initContextTrees(nAlts); }
private void transitionBetweenStates(NFAState a, NFAState b, int label) { Transition e = new Transition(label,b); a.addTransition(e); } }
/** Resolve state d by choosing exit alt, which is same value as the * number of alternatives. Return that exit alt. */ protected int resolveByPickingExitAlt(DFAState d, Set<Integer> nondeterministicAlts) { int exitAlt = dfa.getNumberOfAlts(); turnOffOtherAlts(d, exitAlt, nondeterministicAlts); return exitAlt; }
public NFAConfiguration addNFAConfiguration(NFAState state, int alt, NFAContext context, SemanticContext semanticContext) { NFAConfiguration c = new NFAConfiguration(state.stateNumber, alt, context, semanticContext); addNFAConfiguration(state, c); return c; }
@Override public SemanticContext getGatedPredicateContext() { SemanticContext result = null; for (SemanticContext semctx : operands) { SemanticContext gatedPred = semctx.getGatedPredicateContext(); if ( gatedPred!=null ) { result = combinePredicates(result, gatedPred); } } return result; }
/** Return a string like "3:22: ( A {;} | B )" that describes this * decision. */ public String getDescription() { return dfa.getNFADecisionStartState().getDescription(); }
public NFAToDFAConverter(DFA dfa) { this.dfa = dfa; int nAlts = dfa.getNumberOfAlts(); initContextTrees(nAlts); }