/** * Parses content of a Reader. * * @param reader Reader to parse from * @return Resulting AST * @throws IOException * @throws RecognitionException */ public Optional<cpp14._ast.ASTAsmdefinition> parse(Reader reader) throws IOException, RecognitionException { CPP14Lexer lexer = new CPP14Lexer(new ANTLRInputStream(reader)); CommonTokenStream tokens = new CommonTokenStream(lexer); CPP14Parser parser = new CPP14Parser(tokens); lexer.setMCParser(parser); parser.setFilename("Reader"); cpp14._ast.ASTAsmdefinition ast = parse(parser); if (parser.hasErrors()) { hasErrors = true; return Optional.<cpp14._ast.ASTAsmdefinition>empty(); } return Optional.ofNullable(ast); }
/** * Parses a file. * * @param filename Name of file to parse * @return Resulting AST * @throws IOException * @throws RecognitionException */ public Optional<cpp14._ast.ASTNoexceptexpression> parse(String filename) throws IOException, RecognitionException { CPP14Lexer lexer = new CPP14Lexer(new ANTLRFileStream(filename)); CommonTokenStream tokens = new CommonTokenStream(lexer); CPP14Parser parser = new CPP14Parser(tokens); lexer.setMCParser(parser); parser.setFilename(filename); cpp14._ast.ASTNoexceptexpression ast = parse(parser); if (parser.hasErrors()) { hasErrors = true; return Optional.<cpp14._ast.ASTNoexceptexpression>empty(); } return Optional.ofNullable(ast); }