[antlr-interest] Solution for specialStateTransition exceeding 65k
Marcus Klimstra
mgb.klimstra at gmail.com
Thu May 27 02:18:43 PDT 2010
Hi,
I ran into the problem of the huge specialStateTransition bytecode size when
using many gated semantic predicates in the lexer (in all my lexer rules
actually). After a google search I found that this is a known issue to
which there are some workarounds, but no real solutions. At first I used the
workaround to manually add local variables for the outer-class references,
but at some point even that no longer worked. Therefore I changed the Java
code generator to create seperate methods for each switch-case. This works
quite well for me, so I wanted to share it with the community. Note that I
only tested this in the lexer, since my parser has no
specialStateTransition-method at the moment. I also added annotations to
suppress the useless warnings in the generated code. A diff-file with these
changes is attached.
- Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Java.stg.diff
Type: application/octet-stream
Size: 2734 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20100527/ccf2bb3e/attachment.obj
More information about the antlr-interest
mailing list