public FuckedLexer(CharStream input) { super(input); setInterpreter(new LexerATNSimulator(this, _ATN, getDFA(), new PredictionContextCache())); }
@Override public PredictionContext appendContext(int returnContext, PredictionContextCache contextCache) { return contextCache.getChild(this, returnContext); }
public PredictionContext getChild(PredictionContext context, int invokingState) { if (!enableCache) { return context.getChild(invokingState); } PredictionContextAndInt operands = new PredictionContextAndInt(context, invokingState); PredictionContext result = childContexts.get(operands); if (result == null) { result = context.getChild(invokingState); result = getAsCached(result); childContexts.put(operands, result); } return result; }
joinedCheckContext = contextCache.join(joinedCheckContext, configs.get(i).getContext()); joinedCheckContext = contextCache.join(joinedCheckContext, config2.getContext()); joinedCheckContext2 = contextCache.join(joinedCheckContext2, config2.getContext()); PredictionContext check = contextCache.join(joinedCheckContext, joinedCheckContext2); if (!joinedCheckContext.equals(check)) { return null;
public PredictionContext join(PredictionContext x, PredictionContext y) { if (!enableCache) { return PredictionContext.join(x, y, this); } IdentityCommutativePredictionContextOperands operands = new IdentityCommutativePredictionContextOperands(x, y); PredictionContext result = joinContexts.get(operands); if (result != null) { return result; } result = PredictionContext.join(x, y, this); result = getAsCached(result); joinContexts.put(operands, result); return result; }
final int context1size = context1.size(); if (context0size == 1 && context1size == 1 && context0.getReturnState(0) == context1.getReturnState(0)) { PredictionContext merged = contextCache.join(context0.getParent(0), context1.getParent(0)); if (merged == context0.getParent(0)) { return context0; while (leftIndex < context0size && rightIndex < context1size) { if (context0.getReturnState(leftIndex) == context1.getReturnState(rightIndex)) { parentsList[count] = contextCache.join(context0.getParent(leftIndex), context1.getParent(rightIndex)); returnStatesList[count] = context0.getReturnState(leftIndex); canReturnLeft = canReturnLeft && parentsList[count] == context0.getParent(leftIndex);
private static void modifyInterpreter(final NaturalLanguageStrategyLexer l) { final int originalSize = l.getInterpreter().decisionToDFA.length; final DFA[] emptyDFA = new DFA[originalSize]; // give our own array so the static one isn't used final LexerATNSimulator newInterpreter = new LexerATNSimulator(l, l.getATN(), emptyDFA, new PredictionContextCache()); newInterpreter.clearDFA(); // initialize our array so that the lexer functions properly l.setInterpreter(newInterpreter); // replace the interpreter to bypass all static caches }
@Override public PredictionContext appendContext(PredictionContext suffix, PredictionContextCache contextCache) { return contextCache.getChild(parent.appendContext(suffix, contextCache), returnState); }
private static void modifyInterpreter(final NaturalLanguageStrategyLexer l) { final int originalSize = l.getInterpreter().decisionToDFA.length; final DFA[] emptyDFA = new DFA[originalSize]; // give our own array so the static one isn't used final LexerATNSimulator newInterpreter = new LexerATNSimulator(l, l.getATN(), emptyDFA, new PredictionContextCache()); newInterpreter.clearDFA(); // initialize our array so that the lexer functions properly l.setInterpreter(newInterpreter); // replace the interpreter to bypass all static caches }
@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); }
private static void modifyInterpreter(final NaturalLanguageStrategyParser p) { final int originalSize = p.getInterpreter().decisionToDFA.length; final DFA[] emptyDFA = new DFA[originalSize]; // give our own array so the static one isn't used final ParserATNSimulator newInterpreter = new ParserATNSimulator(p, p.getATN(), emptyDFA, new PredictionContextCache()); newInterpreter.clearDFA(); // initialize our array so that the parser functions properly p.setInterpreter(newInterpreter); // replace the interpreter to bypass all static caches }
private static void modifyInterpreter(final NaturalLanguageStrategyParser p) { final int originalSize = p.getInterpreter().decisionToDFA.length; final DFA[] emptyDFA = new DFA[originalSize]; // give our own array so the static one isn't used final ParserATNSimulator newInterpreter = new ParserATNSimulator(p, p.getATN(), emptyDFA, new PredictionContextCache()); newInterpreter.clearDFA(); // initialize our array so that the parser functions properly p.setInterpreter(newInterpreter); // replace the interpreter to bypass all static caches }
private static GLSLParser getParser( InputStream inputStream, ParseTreeListener listener) throws IOException { ANTLRInputStream input = new ANTLRInputStream(inputStream); GLSLLexer lexer = new GLSLLexer(input); PredictionContextCache cache = new PredictionContextCache(); lexer.setInterpreter( new LexerATNSimulator(lexer, lexer.getATN(), lexer.getInterpreter().decisionToDFA, cache)); CommonTokenStream tokens = new CommonTokenStream(lexer); GLSLParser parser = new GLSLParser(tokens); if (listener != null) { parser.addParseListener(listener); } parser.setInterpreter( new ParserATNSimulator(parser, parser.getATN(), parser.getInterpreter().decisionToDFA, cache)); return parser; }
PredictionContextCache cache = new PredictionContextCache();
PredictionContextCache cache = new PredictionContextCache();
PredictionContextCache contextCache = new PredictionContextCache(); while (true) { // while more work SimulatorState nextState = computeReachSet(dfa, previous, t, contextCache);