Package org.antlr.runtime

Examples of org.antlr.runtime.ANTLRFileStream


/*
      if ( lexer==null ) {
        lexer = new JavaLexer((org.antlr.runtime.CharStream)null);
      }
*/
      lexer = new JavaLexer(new ANTLRFileStream(f));
      CommonTokenStream tokens = new CommonTokenStream();
      tokens.setTokenSource(lexer);

/*
  for (Object t : tokens.getTokens()) {
View Full Code Here


public class Main {
    public static void main(String... args) throws Exception {
        String filePath = args[0];
        String toDir = args.length > 1? args[1] :
                new File(new File(filePath).getParentFile(), "gen").getAbsolutePath();
        GrammarLexer lex = new GrammarLexer(new ANTLRFileStream(filePath));
        CommonTokenStream tokens = new CommonTokenStream(lex);
        GrammarParser parser = new GrammarParser(tokens);

        CommonTree tree = parser.file().tree;
        System.out.println(dumpTree(tree, new StringBuilder(), 0));
View Full Code Here

  public static void main(String[] args) {
    if (args.length == 0) {
      // To do: write usage
    }
    else try {
      ANTLRFileStream input = new ANTLRFileStream(args[0]);
      YANLLexer lexer = new YANLLexer(input);
     
      CommonTokenStream tokens = new CommonTokenStream (lexer);
      YANLParser parser = new YANLParser(tokens);
       
View Full Code Here

  }

  private RutaModule loadScript(String scriptLocation, TypeSystemDescription localTSD)
          throws IOException, RecognitionException {
    File scriptFile = new File(scriptLocation);
    CharStream st = new ANTLRFileStream(scriptLocation, scriptEncoding);
    RutaLexer lexer = new RutaLexer(st);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    RutaParser parser = new RutaParser(tokens);
    parser.setLocalTSD(localTSD);
    parser.setExternalFactory(factory);
View Full Code Here

    }
  }

  private RutaModule loadScript(String scriptLocation) throws IOException, RecognitionException {
    File scriptFile = new File(scriptLocation);
    CharStream st = new ANTLRFileStream(scriptLocation, scriptEncoding);
    RutaLexer lexer = new RutaLexer(st);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    RutaParser parser = new RutaParser(tokens);
    parser.setExternalFactory(factory);
    parser.setResourcePaths(resourcePaths);
View Full Code Here

    public PythonTree parse(String[] args) throws Exception {
        PythonTree result = null;
        //ErrorHandler eh = new ListErrorHandler();
        ErrorHandler eh = new FailFastHandler();
        CharStream input = new ANTLRFileStream(args[0]);
        PythonLexer lexer = new PythonLexer(input);
        lexer.setErrorHandler(eh);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        PythonTokenSource indentedSource = new PythonTokenSource(tokens, args[0]);
        tokens = new CommonTokenStream(indentedSource);
View Full Code Here

public class PythonPartialTester {

  public void parse(String[] args) throws Exception {
        try {
            PythonTree result = null;
            CharStream input = new ANTLRFileStream(args[0]);
            PythonPartialLexer lexer = new PythonPartialLexer(input);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>");
            tokens = new CommonTokenStream(indentedSource);
            PythonPartialParser parser = new PythonPartialParser(tokens);
View Full Code Here

    }

    public static void main(String[] args) {
        CharStream in = null;
        try {
            in = new ANTLRFileStream(args[0]);
        } catch (Exception x) {
            x.printStackTrace();
        }
        AnalyzingParser p = new AnalyzingParser(in, args[0], "ascii");
        mod ast = p.parseModule();
View Full Code Here

    }

    private mod invokeANTLR(String filename) {
        CharStream text = null;
        try {
            text = new ANTLRFileStream(filename);
        } catch (IOException iox) {
            fine(filename + ": " + iox);
            return null;
        }
        return invokeANTLR(text, filename);
View Full Code Here

  public static void checkGrammar (String grammarFilePath) throws IOException, RecognitionException {
    System.err.println("Checking grammar..");
    //====== Syntax check
//    System.err.println("===============");
//    System.err.println("Syntax");
    FTLSyntaxLexer lex = new FTLSyntaxLexer(new ANTLRFileStream(grammarFilePath));
        CommonTokenStream tokens = new CommonTokenStream(lex);
        FTLSyntaxParser parser = new FTLSyntaxParser (tokens);
        FTLSyntaxParser.root_return r = parser.root();       
       
    //====== Sort top levels
View Full Code Here

TOP

Related Classes of org.antlr.runtime.ANTLRFileStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.