Parser Generator for C++

P

pmatos

Hi all,

I need to create a parser in C++ which should parse a somewhat complex
file structure. Yeah, it would be possible to write it from scratch in
C++ however I think it would be easier and the end-result would
probably be more efficient if I use a parser generator. However, I only
know flex/bison from a project in C along time ago. Any ideas on what
to use nowadays and for C++ would be nice.

Cheers,

Paulo Matos
 
V

Victor Bazarov

pmatos said:
I need to create a parser in C++ which should parse a somewhat complex
file structure. Yeah, it would be possible to write it from scratch in
C++ however I think it would be easier and the end-result would
probably be more efficient if I use a parser generator. However, I only
know flex/bison from a project in C along time ago. Any ideas on what
to use nowadays and for C++ would be nice.

AFAIK people who care and who can define the grammar of their files still
use lex/yacc (or their equivalents) to do the job.

V
 
J

Jeff Flinn

pmatos said:
Hi all,

I need to create a parser in C++ which should parse a somewhat complex
file structure. Yeah, it would be possible to write it from scratch in
C++ however I think it would be easier and the end-result would
probably be more efficient if I use a parser generator. However, I
only know flex/bison from a project in C along time ago. Any ideas on
what to use nowadays and for C++ would be nice.

How about boost.spirit at http://www.boost.org/libs/spirit/index.html

Jeff F
 
M

Matthias

Victor said:
AFAIK people who care and who can define the grammar of their files still
use lex/yacc (or their equivalents) to do the job.

V

We had to use a flex/bison parser for a C++ project and had a hard time
calming the compiler to compile the generated code at all (g++)...
I think his question was reasonable and I'd be interested, too, if there
is such a thing for C++.
 
C

Chris Theis

Matthias said:
We had to use a flex/bison parser for a C++ project and had a hard time
calming the compiler to compile the generated code at all (g++)...
I think his question was reasonable and I'd be interested, too, if there
is such a thing for C++.

I´d refer to COCO (www.ssw.uni-linz.ac.at/Research/Projects/Coco/) which
will create code for C, C++, Pascal, C#, Java, etc....

Chris
 
A

Anoop Aryal

Matthias said:
We had to use a flex/bison parser for a C++ project and had a hard time
calming the compiler to compile the generated code at all (g++)...
I think his question was reasonable and I'd be interested, too, if there
is such a thing for C++.

did you look at bison++ ?

aaryal
 
M

Matthias

pmatos said:
Hi, seems
http://www.mactech.com/articles/mactech/Vol.16/16.07/UsingFlexandBison/
used flex and bison with C++, never tried but if you say it isn't worth
it because resulting code is not g++ complaint, then I'll not even try.

Thanks for the remark,

Paulo Matos

Well, at least I have to disable all warnings and the -pedantic flag, as
well as declaring some functions as extern "C" to make the compiler
happy. But it works, if you can live with that :)

But at least three suggestions have been posted by the fellow posters
which sound very appropriate for your purpose, so I guess you're better
off with those pure C++ solutions.
 
J

Jeff Flinn

pmatos said:
Have you tried it yet? Is it nice?

I've been using it for two years in commercial applications. Previous to
spirit I avoid parsing issues as much as possible. Now I look for
opportunites whenever I can! :)

Jeff
 
R

Ralph Juhnke

pmatos said:
Hi all,

I need to create a parser in C++ which should parse a somewhat complex
file structure. Yeah, it would be possible to write it from scratch in
C++ however I think it would be easier and the end-result would
probably be more efficient if I use a parser generator. However, I only
know flex/bison from a project in C along time ago. Any ideas on what
to use nowadays and for C++ would be nice.

Cheers,

Paulo Matos

I like ANTLR www.antlr.org

Ralph
 
P

pmatos

Hi,

Although there were many suggestions and thank you all for the
suggestions I sticked with Spirit, I can tell you that the parser is
almost done. The library is just great! :D

Cheers,

Paulo Matos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top