A grammar for Java 1.7, but unable to test it

50 views
Skip to first unread message

Etienne Gagnon

unread,
Nov 19, 2012, 10:59:46 AM11/19/12
to sab...@googlegroups.com
Hi all,

I've been working, lately, at extracting the Java 1.7 grammar out of the Java Language Specification (JLS), and resolving its conflicts. I've learned a lot in the process (errors in the spec, differences between the spec and the provided LL grammar in appendix, etc.). The resulting annotated grammar is nice, but I have a problem.

The grammar takes over 3 hours for SableCC to compile on my system using the following command:
$ java -d64 -Xms6144m -Xmx6144m  -jar /Applications/sablecc-3.6/lib/sablecc.jar -d tmp java-1.7.sablecc
Observing memory usage, I can confirm that it takes more than 3 GB of memory for SableCC not to run out of memory. I have 8 GB on my system, so I was able to compile it.

Now, the problem is that, when I try to compile the generated Parser.java file (291258 lines), I get:
$ javac org/sablecc/grammars/java_1_7/parser/Parser.java 


The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
	at com.sun.tools.javac.util.Position$LineMapImpl.build(Position.java:139)
	at com.sun.tools.javac.util.Position.makeLineMap(Position.java:63)
	at com.sun.tools.javac.parser.Scanner.getLineMap(Scanner.java:1105)
	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:512)
	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550)
	at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:804)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
	at com.sun.tools.javac.main.Main.compile(Main.java:353)
	at com.sun.tools.javac.main.Main.compile(Main.java:279)
	at com.sun.tools.javac.main.Main.compile(Main.java:270)
	at com.sun.tools.javac.Main.compile(Main.java:69)
	at com.sun.tools.javac.Main.main(Main.java:54)
Does any of you know a way to provide an option similar to "java -Xmx6144m" to javac?

Thanks,

Etienne
-- 
Etienne Gagnon, Ph.D.
http://sablecc.org

Niklas Matthies

unread,
Nov 19, 2012, 11:40:57 AM11/19/12
to sab...@googlegroups.com
Hi Etienne,

Use "-J-Xmx6144m" (cf. [1]).

Niklas

[1] http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#options)
> --
> -- You received this message because you are subscribed to the SableCC group.
> To post to this group, send email to sab...@googlegroups.com. To unsubscribe
> from this group, send email to sablecc+u...@googlegroups.com. For more
> options, visit this group at https://groups.google.com/d/forum/sablecc?hl=en
>
>


Robert Jakob

unread,
Nov 19, 2012, 11:42:33 AM11/19/12
to sab...@googlegroups.com
Hi Etienne,

the -J<flags> seems to be what you are looking for.
-J passes the flags afterwards directly to the underlying runtime system.

Example:
javac -J-Xms256m -J-Xmx256m Test.java

Using ant:
|<||javac||||| ...
||
|||memoryinitialsize||=||"256m"|
|||memorymaximumsize||=||"256m"||>
...
|
|</||javac||>|

Hope this helps.

Robert
> -Xmx6144m" to /javac/?
>
> Thanks,
>
> Etienne
> --
> Etienne Gagnon, Ph.D.
> http://sablecc.org

Etienne Gagnon

unread,
Nov 19, 2012, 11:47:26 AM11/19/12
to sab...@googlegroups.com
Thanks a lot, Robert, Niklas and Olivier!

Etienne

Etienne Gagnon, Ph.D.
http://sablecc.org

Etienne Gagnon

unread,
Nov 19, 2012, 11:57:30 AM11/19/12
to sab...@googlegroups.com
Of course, I should have expected it...

javac -J-d64 -J-Xms6144m -J-Xmx6144m org/sablecc/grammars/java_1_7/parser/Parser.java 
org/sablecc/grammars/java_1_7/parser/Parser.java:105: code too large
    public Start parse() throws ParserException, LexerException, IOException
                 ^
1 error

I think I'll leave this grammar aside for SableCC 4. Fixing the above problem would require too big a change to SableCC 3's code generation.

If anybody is interested, I can add the annotated grammar to the site, though.

Etienne
Reply all
Reply to author
Forward
0 new messages