waxeye-org / waxeye

Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, JavaScript, Python, Racket, and Ruby.
https://waxeye-org.github.io/waxeye/index.html
Other
235 stars 38 forks source link

Java Generation: Large grammars result in "code too large" errors #102

Closed michael-becker closed 4 years ago

michael-becker commented 4 years ago

The Java implementation currently generares all code of the state machine into the method makeAutomata. However, with larger grammars this results in the java error "code too large", since a single method in a Java class may be at most 64KB of bytecode.

As a workaround, it is possible to touch the generated code manually and split the method makeAutomata into two (or more) methods, i.e. I have in makeAutomate the statement: return makeAutomata2(edges,states,automata); and the method private static List<FA<Type>> makeAutomata2(List<Edge<Type>> edges, List<State<Type>> states, List<FA<Type>> automata) {...}

Maybe it is possible to split the method during generation, e.g. after generating about generating 1000 lines of code, makeAutomata2 will be called and so on.

michael-becker commented 4 years ago

As I have seen, the current Java version distributes the parser rules over different methods. Thus, this issue is no longer relevant.