org.antlr.v4.runtime.atn.PredictionContextCache Java Examples
The following examples show how to use
org.antlr.v4.runtime.atn.PredictionContextCache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaFileParser.java From depends with MIT License | 6 votes |
@Override public void parse() throws IOException { CharStream input = CharStreams.fromFileName(fileFullPath); Lexer lexer = new JavaLexer(input); lexer.setInterpreter(new LexerATNSimulator(lexer, lexer.getATN(), lexer.getInterpreter().decisionToDFA, new PredictionContextCache())); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); ParserATNSimulator interpreter = new ParserATNSimulator(parser, parser.getATN(), parser.getInterpreter().decisionToDFA, new PredictionContextCache()); parser.setInterpreter(interpreter); JavaListener bridge = new JavaListener(fileFullPath, entityRepo,inferer); ParseTreeWalker walker = new ParseTreeWalker(); try { walker.walk(bridge, parser.compilationUnit()); Entity fileEntity = entityRepo.getEntity(fileFullPath); ((FileEntity)fileEntity).cacheAllExpressions(); interpreter.clearDFA(); bridge.done(); }catch (Exception e) { System.err.println("error encountered during parse..." ); e.printStackTrace(); } }
Example #2
Source File: ParseHelper.java From graphicsfuzz with Apache License 2.0 | 6 votes |
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); // Remove error listeners, otherwise errors get output to the console. parser.removeErrorListeners(); if (listener != null) { parser.addParseListener(listener); } parser.setInterpreter( new ParserATNSimulator(parser, parser.getATN(), parser.getInterpreter().decisionToDFA, cache)); return parser; }
Example #3
Source File: AntlrATNCacheFields.java From presto with Apache License 2.0 | 4 votes |
public AntlrATNCacheFields(ATN atn) { this.atn = requireNonNull(atn, "atn is null"); this.predictionContextCache = new PredictionContextCache(); this.decisionToDFA = createDecisionToDFA(atn); }
Example #4
Source File: PositionAdjustingLexerATNSimulator.java From beakerx with Apache License 2.0 | 4 votes |
public PositionAdjustingLexerATNSimulator(Lexer recog, ATN atn, DFA[] decisionToDFA, PredictionContextCache sharedContextCache) { super(recog, atn, decisionToDFA, sharedContextCache); }