Greetings,

I am trying to use an ANTLR parser to parse a huge file but runs into a Java Error indicating out of heap space. The grammar (as follows) itself is relatively simple. After going over some posts, I do not believe that UnbufferedTokenStream is an option because white-space is to be ignored in the input file...Also, UnbufferedTokenStream is not available in ANTLRv3.2 which is what I am using...Any advise is greatly appreciated....

   file    :    line+
            ;
   line    :    STRING ID data ';'
            ;
   data    :    primitive | sequence
            ;
   primitive
            :    INTEGER
            ;
   sequence
            :    '{' data? (',' data?)* '}'
            ;

   INTEGER :    ('0'..'9')+
            ;

   STRING  :    '"' ~('"')* '"'
            ;

   ID      :       ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'-')*
            ;

   COMMENT :    '!' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
            ;

   WS      :   ( ' '
            |       '\t'
            |       '\r'
            |       '\n' ) {$channel=HIDDEN;}
            ;

Following is the Java error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at org.antlr.runtime.Lexer.emit(Lexer.java:151)
        at org.antlr.runtime.Lexer.nextToken(Lexer.java:86)
at org.antlr.runtime.CommonTokenStream.fillBuffer(CommonTokenStream.java:119) at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:238) at org.antlr.runtime.CommonTokenStream.LA(CommonTokenStream.java:300)
        at parser.FileImportParser.file(FileImportParser.java:56)
        at test.FileImport.main(FileImport.java:42)

-mahesh
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to