[antlr-interest] Does ANTLR read the entire file before parsing?

siva.kumar at loglogic.com siva.kumar at loglogic.com
Tue Jul 1 13:48:41 PDT 2008


Hi,
   Just wanted confirmation that ANTLR will generate code that will read
the entire file before it's passed to the lexer.

That is, this is the typical use (I've removed the actual grammar but
it's quite simple):


  public static void main(String[] args) throws Exception {
        testLexer lex = new testLexer(new ANTLRFileStream(args[0]));
        CommonTokenStream tokens = new CommonTokenStream(lex);

        testParser parser = new testParser(tokens);

        try {
            parser.line();
        } catch (RecognitionException e)  {
            e.printStackTrace();
        }
  }

I had posted a question earlier with a problem reading large files and
from the responses it appears to be the only way.

Thanks,
-Siva



More information about the antlr-interest mailing list