@Override public final ATNConfig clone() { return transform(this.getState(), false); }
public final ATNConfig transform(@NotNull ATNState state, LexerActionExecutor lexerActionExecutor, boolean checkNonGreedy) { return transform(state, context, this.getSemanticContext(), checkNonGreedy, lexerActionExecutor); }
public ATNConfig appendContext(int context, PredictionContextCache contextCache) { PredictionContext appendedContext = getContext().appendContext(context, contextCache); ATNConfig result = transform(getState(), appendedContext, false); return result; }
public ATNConfig appendContext(PredictionContext context, PredictionContextCache contextCache) { PredictionContext appendedContext = getContext().appendContext(context, contextCache); ATNConfig result = transform(getState(), appendedContext, false); return result; }
public final ATNConfig transform(@NotNull ATNState state, boolean checkNonGreedy) { return transform(state, this.context, this.getSemanticContext(), checkNonGreedy, this.getLexerActionExecutor()); }
@NotNull protected ATNConfig actionTransition(@NotNull ATNConfig config, @NotNull ActionTransition t) { if ( debug ) System.out.println("ACTION edge "+t.ruleIndex+":"+t.actionIndex); return config.transform(t.target, false); }
public final ATNConfig transform(@NotNull ATNState state, @NotNull SemanticContext semanticContext, boolean checkNonGreedy) { return transform(state, this.context, semanticContext, checkNonGreedy, this.getLexerActionExecutor()); }
@Nullable protected ATNConfig predTransition(@NotNull ATNConfig config, @NotNull PredicateTransition pt, boolean collectPredicates, boolean inContext) { if ( debug ) { System.out.println("PRED (collectPredicates="+collectPredicates+") "+ pt.ruleIndex+":"+pt.predIndex+ ", ctx dependent="+pt.isCtxDependent); if ( parser != null ) { System.out.println("context surrounding pred is "+ parser.getRuleInvocationStack()); } } ATNConfig c; if ( collectPredicates && (!pt.isCtxDependent || (pt.isCtxDependent&&inContext)) ) { SemanticContext newSemCtx = SemanticContext.and(config.getSemanticContext(), pt.getPredicate()); c = config.transform(pt.target, newSemCtx, false); } else { c = config.transform(pt.target, false); } if ( debug ) System.out.println("config from pred transition="+c); return c; }
public final ATNConfig transform(@NotNull ATNState state, @Nullable PredictionContext context, boolean checkNonGreedy) { return transform(state, context, this.getSemanticContext(), checkNonGreedy, this.getLexerActionExecutor()); }
@Nullable protected ATNConfig precedenceTransition(@NotNull ATNConfig config, @NotNull PrecedencePredicateTransition pt, boolean collectPredicates, boolean inContext) { if ( debug ) { System.out.println("PRED (collectPredicates="+collectPredicates+") "+ pt.precedence+">=_p"+ ", ctx dependent=true"); if ( parser != null ) { System.out.println("context surrounding pred is "+ parser.getRuleInvocationStack()); } } ATNConfig c; if (collectPredicates && inContext) { SemanticContext newSemCtx = SemanticContext.and(config.getSemanticContext(), pt.getPredicate()); c = config.transform(pt.target, newSemCtx, false); } else { c = config.transform(pt.target, false); } if ( debug ) System.out.println("config from pred transition="+c); return c; }
RuleTransition ruleTransition = (RuleTransition)t; if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.getContext().hasEmpty()) { c = config.transform(t.target, true); c = config.transform(t.target, newContext, true); c = config.transform(t.target, true); c = config.transform(t.target, lexerActionExecutor, true); break; c = config.transform(t.target, true); break; c = config.transform(t.target, true); break; if (treatEofAsEpsilon) { if (t.matches(CharStream.EOF, Lexer.MIN_CHAR_VALUE, Lexer.MAX_CHAR_VALUE)) { c = config.transform(t.target, false); break;
@Nullable protected ATNConfig getEpsilonTarget(@NotNull ATNConfig config, @NotNull Transition t, boolean collectPredicates, boolean inContext, PredictionContextCache contextCache, boolean treatEofAsEpsilon) { switch (t.getSerializationType()) { case Transition.RULE: return ruleTransition(config, (RuleTransition)t, contextCache); case Transition.PRECEDENCE: return precedenceTransition(config, (PrecedencePredicateTransition)t, collectPredicates, inContext); case Transition.PREDICATE: return predTransition(config, (PredicateTransition)t, collectPredicates, inContext); case Transition.ACTION: return actionTransition(config, (ActionTransition)t); case Transition.EPSILON: return config.transform(t.target, false); case Transition.ATOM: case Transition.RANGE: case Transition.SET: // EOF transitions act like epsilon transitions after the first EOF // transition is traversed if (treatEofAsEpsilon) { if (t.matches(Token.EOF, 0, 1)) { return config.transform(t.target, false); } } return null; default: return null; } }
@NotNull protected ATNConfig ruleTransition(@NotNull ATNConfig config, @NotNull RuleTransition t, @Nullable PredictionContextCache contextCache) { if ( debug ) { System.out.println("CALL rule "+getRuleName(t.target.ruleIndex)+ ", ctx="+config.getContext()); } ATNState returnState = t.followState; PredictionContext newContext; if (optimize_tail_calls && t.optimizedTailCall && (!tail_call_preserves_sll || !PredictionContext.isEmptyLocal(config.getContext()))) { newContext = config.getContext(); } else if (contextCache != null) { newContext = contextCache.getChild(config.getContext(), returnState.stateNumber); } else { newContext = config.getContext().getChild(returnState.stateNumber); } return config.transform(t.target, newContext, false); }
configs.add(config.transform(config.getState(), PredictionContext.EMPTY_FULL, true)); currentAltReachedAcceptState = true; ATNConfig c = config.transform(returnState, newContext, false); currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
if (closure(input, c.transform(target, lexerActionExecutor, true), reach, currentAltReachedAcceptState, true, treatEofAsEpsilon)) {
configSet.add(config.transform(config.getState(), updatedContext, false), contextCache);
ATNState target = getReachableTarget(c, trans, t); if ( target!=null ) { reachIntermediate.add(c.transform(target, false), contextCache);
c = c.transform(c.getState(), SemanticContext.NONE, false); dup.add(c);