[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SableCC event driven?



This works for the SableCC 3. Which is in beta status
right now but seems to work for most people for most things.

The procedure would be something like this:

* Get the alternative sablecc from my homepage -
    http://www.mare.ee/indrek/sablecc/
It should be installable just like the regular sablecc
package.

* Make your own copy of the Java backend:
    cp -r sablecc-blaah.blaah/src/org/sablecc/sablecc/xss2/data/java/ myjava/
You made a copy of the java xss files. These files are
also in the .jar files so you could also get them from there.

* Modify the xss templates as you see fit. Add support
for event driven lexer - see lexer.xss. There are some
docs under the docs/ dir about xss. And existing
backends should give you a hint on what is going on.
Also see my homepage for info.

* Run Sablecc on your xss templates:
    sablecc -t myjava/main.xss mygrammar.sablecc3

Now if the changes are more general and you think other
people might and should benefit from them, you might
want to share your changes. There are three ways for that:

1) You'll make an alternative complete backend. If the
changes are major over all the generated output that
would be the way to go. Probably your changes are
not that major. You'd also become the maintainer of
the new backend.

2) You'll just make a single xss file that is added to the
sablecc distribution and who'se sole purpose is it
to genereate Lexer.java for the java backend.
This is a milder variant of the previous and could be
implemented in terms of third.

3) You make your changes permanent or parameter
based to the existing java backend. This would
probably be the best for what you want to do.

Permanent if the code you add would not disrupt existing
systems/API.

Parameter based when they would.

So for parameter based execution in theory
when somebody executes sablecc and adds
    -p event_diven_lexer 1
then the lexer that is generated will be event driven.
For that you have to test the parameter value inside
the xss and output "old" traditional code if it's not set
and output your changes if it is.

Now when you make changes and think they'd be
good for other people make a patch/diff and send
to the maintainer of Java backend.

That would probably be Etienne Gagnon.

Regards,
Indrek


On Monday 19 January 2004 22:31, Jochen Wiedmann wrote:
> Etienne Gagnon wrote:
> > This is an ideal project for testing the new SableCC back-end (look for
> > Indrek's recent message).  Maybe you would be willing to create a
> > template for an event-driven parser?
>
> Could you please give me more details where I ought to look at? I found
> lots of messages with Indrek as a sender.
>
>
> Regards,
>
> Jochen