[antlr-interest] build issues: bytecode assembly generation
Terence Parr
parrt at cs.usfca.edu
Fri Oct 22 08:47:57 PDT 2004
On Oct 22, 2004, at 5:54 AM, Bryan Ewbank wrote:
>
>> I just had another idea. The original problem is "I need gotos in
>> Java."
>
> After all this, do you really need gotos? How's about using a
> while/switch
> combination instead?
>
> It provides the same flexibility - bits of code executed in specific
> orders - but avoids the need to hack the generated code. It's also, at
> least from what I've seen, the usual way to implement NFA/DFA with code
> instead of tables. For example...
>
> int state = START;
> while(state != END)
> {
> switch (state)
> {
> case START:
> ...
> state=20;
> break;
> case 20:
> ...
> state=21;
> if (...) state=42;
> break;
> ... ... ...
> }
> }
Yep, I thought of this too...the problem is that it's too inefficient
once you get many many states in there...not sure how many is too many
either. Certainly Java will impose some limit on the number of cases
as well (255?).
> This still keeps the "pretty much what you'd do by hand" model that
> ANTRL
> uses for other parts of the generated code, and avoids the headaches
> of the
> whole hacking-the-code problem.
Good though Bryan.
Anyway, I have now completed changes to the templates so that they
generate bytecodes instead of Java. I just have to add the concept of
writing a second file and the bytecodes can go to mygrammar_DFA.class.
I have a few improvements to make to the assembler as well. It's
amazing that the template system for 3.0 code generation is happy doing
Java, C, and bytecodes right now...just by changing a template file!!!
Terence
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list