How to create a simple configurationfile parser?

J

Jesper N?hr

Hey there.

I'm writing a small application that has a belonging
configuration-file.

At the moment, I'm parsing the file with basic for-lops, but this is
pretty slow, and also I need to extend the parser to be able to read
more configuration-entries.

A friend of mine told me I should take a look at yacc/lex, and so I
googled for hours for some simple examples on this. I didn't really
find anything useful.

So my question is, could someone please post a simple example on how
to parse generic 'option = value' files with C and yacc/lex?

Thanks in advance.
 
A

Alex

Jesper N?hr said:
I'm writing a small application that has a belonging
configuration-file. [snip]
So my question is, could someone please post a simple example on how
to parse generic 'option = value' files with C and yacc/lex?

If it really is "option = value", yacc/lex is almost certainly overkill. I'm
sure there are plenty of people who have implemented ".ini" file parsers
(which are option/value pairs classified into "sections"), you should be
able to Google up some source...
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top