org.antlr.v4.runtime.atn.ParserATNSimulator Java Examples

The following examples show how to use org.antlr.v4.runtime.atn.ParserATNSimulator. 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 vote down vote up
@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 vote down vote up
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 5 votes vote down vote up
@SuppressWarnings("ObjectEquality")
public void configureParser(Parser parser)
{
    requireNonNull(parser, "parser is null");
    // Intentional identity equals comparison
    checkArgument(atn == parser.getATN(), "Parser ATN mismatch: expected %s, found %s", atn, parser.getATN());
    parser.setInterpreter(new ParserATNSimulator(parser, atn, decisionToDFA, predictionContextCache));
}
 
Example #4
Source File: GroovyLangParser.java    From groovy with Apache License 2.0 5 votes vote down vote up
public GroovyLangParser(TokenStream input) {
    super(input);

    this.setInterpreter(new ParserATNSimulator(this, ParserAtnManager.INSTANCE.getATN()));

    if (GROOVY_PARSER_PROFILING_ENABLED) {
        this.setProfile(true);
    }
}
 
Example #5
Source File: OoxxParser.java    From BigDataArchitect with Apache License 2.0 4 votes vote down vote up
public OoxxParser(TokenStream input) {
	super(input);
	_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
 
Example #6
Source File: DataModelParser.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
public DataModelParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
}
 
Example #7
Source File: XMLParser.java    From manifold with Apache License 2.0 4 votes vote down vote up
public XMLParser( TokenStream input )
{
  super( input );
  _interp = new ParserATNSimulator( this, _ATN, _decisionToDFA, _sharedContextCache );
}
 
Example #8
Source File: FWPolicyParser.java    From development with Apache License 2.0 4 votes vote down vote up
public FWPolicyParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA,
            _sharedContextCache);
}
 
Example #9
Source File: CQLCFParser.java    From chronix.server with Apache License 2.0 4 votes vote down vote up
public CQLCFParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
}
 
Example #10
Source File: SoqlParser.java    From components with Apache License 2.0 4 votes vote down vote up
public SoqlParser(TokenStream input) {
	super(input);
	_interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
       removeErrorListeners();
       addErrorListener(new SoqlErrorListener());
}
 
Example #11
Source File: JaybirdSqlParser.java    From jaybird with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JaybirdSqlParser(TokenStream input) {
	super(input);
	_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
 
Example #12
Source File: BatfishParserATNSimulator.java    From batfish with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a {@link BatfishParserATNSimulator} from a {@link ParserATNSimulator}
 *
 * @param parent The {@link ParserATNSimulator} to emulate modulo {@link #adaptivePredict}.
 */
public BatfishParserATNSimulator(ParserATNSimulator parent) {
  super(parent.getParser(), parent.atn, parent.decisionToDFA, parent.getSharedContextCache());
  setPredictionMode(parent.getPredictionMode());
  _parser = (BatfishParser) parser;
}
 
Example #13
Source File: XpathParser.java    From JsoupXpath with Apache License 2.0 4 votes vote down vote up
public XpathParser(TokenStream input) {
	super(input);
	_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
 
Example #14
Source File: EditorConfigParser.java    From editorconfig-netbeans with MIT License 4 votes vote down vote up
public EditorConfigParser(TokenStream input) {
  super(input);
  _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
}
 
Example #15
Source File: XGBoostModelParser.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new instance of XGBoost model parser.
 *
 * @param input Token stream.
 */
public XGBoostModelParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
}