473,473 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Parser Generator for C++

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
12 2622
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
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
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
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
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

"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
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
Have you tried it yet? Is it nice?

Cheers,

Paulo Matos

Jul 23 '05 #9
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: alederer | last post by:
Hallo! Does anybody know a parser generator that supports unicode (UTF-16), and is based on something like ICU. The parser is used in a platform independent and cross-platform communicating...
3
by: Jang | last post by:
Could anyone point or send me a syntax of C which fits to Parser Generator (YAAC) ? I've got a big problem because I have to write a translator C ->assembler :[ There is a lot of work to...
0
by: jozo | last post by:
I am using bumblebee software PARSER GENERATOR to make a C file from LEX regular definitions. I want to compile that C file with VS .NET but I have problems. Does somebody know how to configure...
0
by: Marcel Linnenfelser | last post by:
Hi there, anyone interested in a php written and outputting LALR(1) parser generator, especially in testing it? I already posted this request in the german newsgroup a few days ago. I noticed...
6
by: Mike C# | last post by:
Hi all, Can anyone recommend a good and *easy to use* lexer and parser generator? Preferably one that was written specifically for VC++ and not mangled through 20 different platforms. I've had...
9
by: Peter Michaux | last post by:
Hi, Does a parser generator exist that generates JavaScript code? Most parser generators generate C or Java code. Thanks, Peter
20
by: Jack | last post by:
Hi all, I need to do syntax parsing of simple naturual languages, for example, "weather of London" or "what is the time", simple things like these, with Unicode support in the syntax. In Java,...
1
by: seaside | last post by:
Hi, I'll probably release a php5-based LL(1) parser generator - if there is general interest. Please post a comment, in case... Some details: - Pure PHP5 - Parses LL(1) - Lexical...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.