Flex / parsers for beginners?

T

Tinkertim

Hello to all,

I've been using C for a long time however I'm about to take my first
splash into making a parser. I have some interesting things to
accomplish and I'm hoping to get some recommended links to tutorials
that might help me jump in.

I will be parsing a configuration file, like this:

vars {
shemp = "not_larry"
lucy = "in the sky with diamonds"
}

group foo {
class bar {
foobar = %lucy%
barfoo = *.txt
}
default = foo
stooge = %shemp% ? %shemp% : "none"
}

There's some interesting stuff going on there, I will need to expand
variables, handle globs and handle stanzas inside stanzas inside
stanzas.

Globbing really doesn't have much to do with the parser, just there as
an example of what I need to accomplish.

I've spent the last few days reading many tutorials on flex, however
many of them assume that I know a little more than I do.

Could some kind soul point to some links that might help me wrap my
head around it?

Thanks in advance!
--Tim
 
C

Chris Dollin

Tinkertim said:
Hello to all,

I've been using C for a long time however I'm about to take my first
splash into making a parser. I have some interesting things to
accomplish and I'm hoping to get some recommended links to tutorials
that might help me jump in.

I will be parsing a configuration file, like this:
(fx:snip)

I've spent the last few days reading many tutorials on flex, however
many of them assume that I know a little more than I do.

flex is not sufficient to your task; it does tokenisation, and you'll
need more general parsing such as is provided by yacc/bison/et al.

comp.unix.programmer would be useful for flex/bison advice, and
perhaps more so (but less C-oriented & more theoretical if needed)
would comp.compilers (it doesn't restrict itself to just "compilers").

flex/bison aren't as such on topic here -- but all sorts of issues
raised using them /are/.
 
T

Tinkertim

[OT] I found the O'Reilly book "lex & yacc" to be an absolutely excellent
guide to lex and yacc, in all their incarnations. It's both a tutorial
and a reference guide. I highly recommend you obtain it and read it
thoroughly. If you can't find or afford it, however, the texinfo pages
for flex and bison are pretty good. [/OT]

Regards,
Tristan

Thanks Tristan, I'll pick up the book. Sorry to go off topic :)

Cheers,
--Tim
 

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,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top