[antlr-interest] DFA's encoded directly in java bytecodes
Robert Colquhoun
rjc at trump.net.au
Wed Oct 27 14:06:56 PDT 2004
At 09:55 AM 27/10/2004, Terence Parr wrote:
>On Oct 26, 2004, at 1:46 PM, Robert Colquhoun wrote:
> > With all the goto'ing I was just wondering if the assembler you have
> > done
> > above implements the bytecode rule "all approaches to a single point
> > must
> > have the same stack"
>
>Well, do you mean that I guarantee/check for this? nope ;) My DFA
>code will keep the stack at 0 minus locals / arguments between states.
Ah ok. Be careful with exceptions, and it can make loops and stuff
marginally slower as you need to read the working set of vars from locals
on each cycle. You also need to remember state for each local var as you
are jumping around.
Have you got a small example of the DFA you are trying to generate? No
need for correct bytecode, just the algorithm/rules are enough...for
reference i can code it up with my generator for comparison.
> > I was stuck on action code and how to do semantic actions, its easy to
> > do
> > as separate actions but hard to do inline.
>
>True, but you could invoke the javac compiler in tools.jar like a web
>server :)
Why bother with tools.jar? antlr has java grammar and i have some bytecode
generating classes all i need is a tree walker to convert them and i can
then inline them in the class file itself (The bytecode generator i have
can insert code at arbitrary points in the method being created, ie run
through the rule doing the bnf and then compile and insert in the java
source action fragments).
It's not like Sun has legions of minions working on their compiler to make
it state of the art...for 1.5 cycle i heard they only had one guy working
on the whole thing!
;-)
I can post these bytecode generating classes if you want, what license are
you using for antlr 3?
- Robert
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