www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Lemonade : Lemon parser generator for D V 0.01

reply Carlos <carlos2003nov yahoo.ca> writes:
Lemonade 0.01 An Lalr Parser Generator for "D"

Based on Lemon 1.0
Ref: http://www.hwaci.com/sw/lemon/

With some modifications:

1. Generate D code (:-)

2. C style preprocessor integrated to allow
    preprocessing of generated D file.

3. ameliorations to some part of the code
    For example:
    Each item of production in grammar, can have
    an alias. THis alias can be use in the code
    executed when reducing the rule.
    Using the alias is a lot more fun thant the
    $n of yacc parsers.

    The "translateCode" function was doing a terrible job
    by replacing all an every occurence of the alias in
    the code. Which was not ok when the alias was inside
    a string. Fixed.

4. Some others things that will be documented later.

The zip files contains all sources (except the code
for the preprocessor. Will be added later)

Compiled with Visual C++ 6.0

There is also a small example, which works.

Documentation for Lemon is available ont the site
of the author.

There is a SourceForge project with somes examples
of Lemon usage.

S/F: http://souptonuts.sourceforge.net/

See: Lemon Parser Tutorial

"Lemon is a compact, thread safe, well-tested parser generator 
written by D. Richard Hipp. Using a parser generator, along with 
a scanner like flex, can be advantageous because there is less 
code to write. You just write the grammar for the parser. This 
article is an introduction to the Lemon Parser, complete with 
examples. "

More to come ( eg: RE2D, made from RE2C )

C
Apr 06 2005
next sibling parent reply "Joey Peters" <squirrel nidhogg.com> writes:
This is pretty nice. Where can I find the template file you used to generate 
ex01.d?

"Carlos" <carlos2003nov yahoo.ca> schreef in bericht 
news:d31bs0$2smg$1 digitaldaemon.com...
 Lemonade 0.01 An Lalr Parser Generator for "D"

 Based on Lemon 1.0
 Ref: http://www.hwaci.com/sw/lemon/

 With some modifications:

 1. Generate D code (:-)

 2. C style preprocessor integrated to allow
    preprocessing of generated D file.

 3. ameliorations to some part of the code
    For example:
    Each item of production in grammar, can have
    an alias. THis alias can be use in the code
    executed when reducing the rule.
    Using the alias is a lot more fun thant the
    $n of yacc parsers.

    The "translateCode" function was doing a terrible job
    by replacing all an every occurence of the alias in
    the code. Which was not ok when the alias was inside
    a string. Fixed.

 4. Some others things that will be documented later.

 The zip files contains all sources (except the code
 for the preprocessor. Will be added later)

 Compiled with Visual C++ 6.0

 There is also a small example, which works.

 Documentation for Lemon is available ont the site
 of the author.

 There is a SourceForge project with somes examples
 of Lemon usage.

 S/F: http://souptonuts.sourceforge.net/

 See: Lemon Parser Tutorial

 "Lemon is a compact, thread safe, well-tested parser generator
 written by D. Richard Hipp. Using a parser generator, along with
 a scanner like flex, can be advantageous because there is less
 code to write. You just write the grammar for the parser. This
 article is an introduction to the Lemon Parser, complete with
 examples. "

 More to come ( eg: RE2D, made from RE2C )

 C



 
Apr 07 2005
parent reply Carlos <carlos2003nov yahoo.ca> writes:
Joey Peters wrote:
 This is pretty nice. Where can I find the template file you used to generate 
 ex01.d?
 
Sorry, forgot to zip it. Lempar.zip contains lempar.d, which is the template for D. This template both use D debug(...) and ifndef NDEBUG to delimit debug code. That won't stay that way. To produce ex01.exe: C:\> lemond ex01.y C:\> dmd ex01.d C:\> ex01 RESULT: 3
Apr 07 2005
parent reply Christoph Singewald <christoph singewald.at> writes:
Did somebody build Lemonade under unix with gcc 4.1.2?
I had to change somt things.
tnx
christoph

Carlos wrote:

 Joey Peters wrote:
 This is pretty nice. Where can I find the template file you used to
 generate ex01.d?
 
Sorry, forgot to zip it. Lempar.zip contains lempar.d, which is the template for D. This template both use D debug(...) and ifndef NDEBUG to delimit debug code. That won't stay that way. To produce ex01.exe: C:\> lemond ex01.y C:\> dmd ex01.d C:\> ex01 RESULT: 3
Jun 02 2007
next sibling parent "Carlos Smith" <carlos-smith sympatico.ca> writes:
: Did somebody build Lemonade under unix with gcc 4.1.2?
: I had to change somt things.

Christoph,

Hey, now that's a surprise!
I was abolutely convince that nobody was actually
using Lemonade !

I have gcc 4.1.2 on Ubuntu feisty.

I will try to buil Lemonade tonight.

Carlos
Jun 02 2007
prev sibling parent reply "Carlos Smith" <carlos-smith sympatico.ca> writes:
Hi again,

I just compiled Lemonade on Ubuntu.

The original Lemon do generate parsers with
imbedded #directives. I did not completely eliminated
those #directives in Lemonade. 

DMD has no preproc. So i decided to add one to Lemonade.
The 2 zip files attached to this post (and
mailed to you in a separate email), are
ulemon.zip - the parser generator.
ucpp.zip - the C preprocessor modified to process D code.

I tested it. it work 98% ok. the 2% is related to the
preprocessing phase. The cpp( ) call at the end of the
main( ) in Lemonc, does not work. (It was working
under Windows. This is my 1st prog on Unix)

I will rework on this later, In the meantime you can
play with it or fix the problem yourself.

Carlos
Jun 02 2007
parent Christoph Singewald <christoph singewald.at> writes:
Hi all!

I created a project for lemonade on Berlios: http://lemonade.berlios.de
I took lempar.d from carlos und ported lemonade.c fresh from  sqllite
repository. I left it in one file like lemon.c to make it easier porting
bugfixes from lemon.c.
 carlos: I oversee to integrate some of youre improovemends, I hope you'll find
some time to reintegrate.

On the News page there are still some points to do.: e.g. %extra_argument in
the Parse(...) function

cu
christoph



Carlos Smith Wrote:

 Hi again,
 
 I just compiled Lemonade on Ubuntu.
 
 The original Lemon do generate parsers with
 imbedded #directives. I did not completely eliminated
 those #directives in Lemonade. 
 
 DMD has no preproc. So i decided to add one to Lemonade.
 The 2 zip files attached to this post (and
 mailed to you in a separate email), are
 ulemon.zip - the parser generator.
 ucpp.zip - the C preprocessor modified to process D code.
 
 I tested it. it work 98% ok. the 2% is related to the
 preprocessing phase. The cpp( ) call at the end of the
 main( ) in Lemonc, does not work. (It was working
 under Windows. This is my 1st prog on Unix)
 
 I will rework on this later, In the meantime you can
 play with it or fix the problem yourself.
 
 Carlos
 
Jun 26 2007
prev sibling parent reply "G.Vidal" <gyvidal wanadoo.fr> writes:
Great but where is it ???
Apr 07 2005
parent Carlos <carlos2003nov yahoo.ca> writes:
G.Vidal wrote:
 Great but where is it ???
 
where is it what ? i guess your news/mail client dont let you see the attached file. i can email it to you if you want. there is a zip file attached to the original post. and i just posted a missing file (lempar.d).
Apr 07 2005