org.antlr.v4.runtime.ANTLRFileStream Java Examples
The following examples show how to use
org.antlr.v4.runtime.ANTLRFileStream.
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: Load.java From cs652 with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] args) throws IOException { ANTLRInputStream input = new ANTLRFileStream("colleges.csv"); CSVLexer lexer = new CSVLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); CSVParser parser = new CSVParser(tokens); ParseTree tree = parser.file(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); CSVLoader loader = new CSVLoader(); walker.walk(loader, tree); for (List<String> row : loader.data) { System.out.println(row); } }
Example #2
Source File: Load.java From cs652 with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] args) throws IOException { ANTLRInputStream input = new ANTLRFileStream("colleges.csv"); CSVLexer lexer = new CSVLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); CSVParser parser = new CSVParser(tokens); ParseTree tree = parser.file(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); CSVLoader loader = new CSVLoader(); walker.walk(loader, tree); for (List<String> row : loader.data) { System.out.println(row); } }
Example #3
Source File: IrisProtoCompiler.java From arcusplatform with Apache License 2.0 | 5 votes |
private static void parse(ASTBuilder builder, String path) throws Exception { ProtocLexer lexer = new ProtocLexer(new ANTLRFileStream(path)); CommonTokenStream tokens = new CommonTokenStream(lexer); ProtocParser parser = new ProtocParser(tokens); FileContext file = parser.file(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(builder, file); }
Example #4
Source File: Dbg.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws Exception { ANTLRv4Lexer lexer = new ANTLRv4Lexer(new ANTLRFileStream("grammars/org/antlr/codebuff/ANTLRv4Lexer.g4")); CommonTokenStream tokens = new CodeBuffTokenStream(lexer); ANTLRv4Parser parser = new ANTLRv4Parser(tokens); ANTLRv4Parser.GrammarSpecContext tree = parser.grammarSpec(); System.out.println(tree.toStringTree(parser)); }
Example #5
Source File: ProfileJava.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws Exception { Thread.sleep(10000); ANTLRFileStream input = new ANTLRFileStream(args[0]); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); JavaParser.CompilationUnitContext tree = parser.compilationUnit(); // System.out.println(tree.toStringTree(parser)); Thread.sleep(10000); }
Example #6
Source File: BNFProcessor.java From openCypher with Apache License 2.0 | 5 votes |
public Grammar processFile(String fileName) { try { // when back on antrl 4.7.1, use CharStreams.fromFileName(scriptFile) return processAntrlStream(new ANTLRFileStream(fileName)); } catch (IOException e) { throw new RuntimeException("Failed to find or read " + fileName, e); } }
Example #7
Source File: G4Processor.java From openCypher with Apache License 2.0 | 5 votes |
public Grammar processFile(String fileName) { try { // when back on antrl 4.7.1, use CharStreams.fromFileName(scriptFile) return processAntrlStream(new ANTLRFileStream(fileName)); } catch (IOException e) { throw new RuntimeException("Failed to find or read " + fileName, e); } }
Example #8
Source File: Test.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws IOException { ANTLRInputStream input = new ANTLRFileStream(args[0]); SimpleLexer l = new SimpleLexer(input); TokenStream tokens = new CommonTokenStream(l); SimpleParser parser = new SimpleParser(tokens); ParserRuleContext tree = parser.file(); System.out.println(tree.toStringTree(parser)); // tree.inspect(parser); DefSymbolsAndScopes def = new DefSymbolsAndScopes(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(def, tree); }
Example #9
Source File: TestFaLaLa.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws Exception { ANTLRInputStream input = new ANTLRFileStream("test.falala"); FaLaLaLexer lexer = new FaLaLaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); FaLaLaParser parser = new FaLaLaParser(tokens); ParseTree tree = parser.prog(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); DefSymbols def = new DefSymbols(); walker.walk(def, tree); }
Example #10
Source File: TestLaLa.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws Exception { ANTLRInputStream input = new ANTLRFileStream("bad.lala"); LaLaLexer lexer = new LaLaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); LaLaParser parser = new LaLaParser(tokens); ParseTree tree = parser.prog(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); DefSymbols def = new DefSymbols(); walker.walk(def, tree); System.out.println(def.globals.symbols); }
Example #11
Source File: Test.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws IOException { ANTLRInputStream input = new ANTLRFileStream(args[0]); SimpleLexer l = new SimpleLexer(input); TokenStream tokens = new CommonTokenStream(l); SimpleParser parser = new SimpleParser(tokens); ParserRuleContext tree = parser.file(); System.out.println(tree.toStringTree(parser)); // tree.inspect(parser); DefSymbolsAndScopes def = new DefSymbolsAndScopes(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(def, tree); }
Example #12
Source File: TestFaLaLa.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws Exception { ANTLRInputStream input = new ANTLRFileStream("test.falala"); FaLaLaLexer lexer = new FaLaLaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); FaLaLaParser parser = new FaLaLaParser(tokens); ParseTree tree = parser.prog(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); DefSymbols def = new DefSymbols(); walker.walk(def, tree); }
Example #13
Source File: TestLaLa.java From cs652 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws Exception { ANTLRInputStream input = new ANTLRFileStream("bad.lala"); LaLaLexer lexer = new LaLaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); LaLaParser parser = new LaLaParser(tokens); ParseTree tree = parser.prog(); System.out.println(tree.toStringTree(parser)); ParseTreeWalker walker = new ParseTreeWalker(); DefSymbols def = new DefSymbols(); walker.walk(def, tree); System.out.println(def.globals.symbols); }
Example #14
Source File: Module.java From QuickProject with Apache License 2.0 | 5 votes |
private void parseBean(File sqlFile, GlobalConfig globalConfig) throws IOException { CharStream input = new ANTLRFileStream(sqlFile.getAbsolutePath()); CreateTableLexer lexer = new CreateTableLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); CreateTableParser parser = new CreateTableParser(tokens); ParseTree tree = parser.sql(); ParseTreeWalker walker = new ParseTreeWalker(); CreateTableListenerImpl extractor = new CreateTableListenerImpl(globalConfig); walker.walk(extractor, tree); beans = extractor.getTables(); }
Example #15
Source File: ExpressionCompiler.java From arcusplatform with Apache License 2.0 | 4 votes |
public static Predicate<Model> compile(File file) throws IOException { return compile(new ANTLRFileStream(file.getAbsolutePath())); }
Example #16
Source File: GDLHandler.java From gdl with Apache License 2.0 | 2 votes |
/** * Initializes GDL Handler from given file. * * @param fileName GDL file (must not be {@code null}). * @return GDL handler */ public GDLHandler buildFromFile(String fileName) throws IOException { ANTLRInputStream antlrInputStream = new ANTLRFileStream(fileName); return build(antlrInputStream); }