A user earlier posted a question about terminating
the grammer for a simple calculator done with lemon.
I ran into the same problem and had to use
the following, which worked fine:
main ::= in.
in ::= .
in ::= in state NEWLINE.
I cannot reduce it any further. For instance,
the following does not work:
in ::= .
in ::= in stmt ENDLINE.
The version of lemon I'm using is from the
cvs 3.0.3.
The full calculator, there are 4 examples, can
be downloaded from the following link:
http://prdownloads.sourceforge.net/souptonuts/lemon_examples.tar.gz?download
Look at example4.y, if you want to go directly to
the terminating issue above. Everything should be in
this download including lemon.c and lempar.c, so you
won't have to download anything else.
Take a look at the README. I tried to add documentation
on creating custom tokens, destructors, and a little bit
on what the grammer does.
To run everything, just run make
$ make
Then, each example can be run separately
$ ./ex1
$ ./ex2
...
$ ./ex4
Anyway, I hope this examples will help. Or
inspire you to take a took at lemon.
Regards,
Mike Chirico