By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,331 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,331 IT Pros & Developers. It's quick & easy.

Parser Generator for C++

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
pmatos wrote:
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
Jul 23 '05 #2

P: n/a
pmatos wrote:
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
Jul 23 '05 #3

P: n/a
Victor Bazarov wrote:
pmatos wrote:
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


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++.

--
Regards,
Matthias
Jul 23 '05 #4

P: n/a
Matthias wrote:
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

Jul 23 '05 #5

P: n/a
Anoop Aryal wrote:
Matthias wrote:
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


No joke? :D
Haven't heard of it yet, but sounds quite like what I'm looking for, thanks!

--
Regards,
Matthias
Jul 23 '05 #6

P: n/a

"Matthias" <no****@digitalraid.com> wrote in message
news:cu*************@news.t-online.com...
Victor Bazarov wrote:
pmatos wrote:
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


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
Jul 23 '05 #7

P: n/a
Hi, seems
http://www.mactech.com/articles/mact...gFlexandBison/
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

Jul 23 '05 #8

P: n/a
Have you tried it yet? Is it nice?

Cheers,

Paulo Matos

Jul 23 '05 #9

P: n/a
pmatos wrote:
Hi, seems
http://www.mactech.com/articles/mact...gFlexandBison/
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.

--
Regards,
Matthias
Jul 23 '05 #10

P: n/a
pmatos wrote:
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
Jul 23 '05 #11

P: n/a
"pmatos" <po**@sat.inesc-id.pt> wrote in message news:<11********************@c13g2000cwb.googlegro ups.com>...
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
Jul 23 '05 #12

P: n/a
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

Jul 23 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.