Mailing List Archive

Implementation of configuration-api
Hi!

I have read config.c and I wounder why flex and yacc are not used for
parse the configuration-files. I suppose that writing that stuff in flex
would not only make the source better readable, but also easier to modify
and extendable.

kind regards, +43-676-4708155
Michael Moerz Systemengineer +43-1-718-98-80
CUBiT www.cubit.at
Implementation of configuration-api [ In reply to ]
Michael Moerz wrote:
>
> Hi!
>
> I have read config.c and I wounder why flex and yacc are not used for
> parse the configuration-files. I suppose that writing that stuff in flex
> would not only make the source better readable, but also easier to modify
> and extendable.

Because it is about 100 times overkill, and the lex/yacc code would not be much
smaller (in source). Also, there are lots of different gotchas in using lex and
yacc (like the inability to handle more than one grammar in a given program)
that I didn't want to try and overcome with in this situation. Additionally,
given the simple syntax of the config file, it would actually be *less* readily
extended in many useful ways than the current code.

I wrote the current code in about an hour. Lex/Yacc would have probably taken
longer, and been impossible to add more file types to parse, and the resulting
code would have been MUCH bigger in object form, and similar in source size.

Other than that, I didn't have any particular reason :-)

Readability in something like this depends on knowing the "patterns" of lexical
analysis in C. If you're familiar with the normal patterns for this, the code
will be readable. If you're only familiar with using lex and yacc, it probably
won't seem clear to you.

I have written several dozen parsers of varying degrees of sophistication, and
many of them used lex and yacc. My engineering judgment was that this structure
was cleaner and better suited to our needs.

I admit that the code for parsing authkeys needs help. I didn't modify that
part of the code enough after I got it. Laziness on my part, I guess.

As we go forward and try and build a more sophisticated (multi-node) cluster, it
*might* be the case that our situation might change and rewriting it might be
better than adding a little to it.

-- Alan Robertson
alanr@bell-labs.com
Implementation of configuration-api [ In reply to ]
Hi!

I admire your knowledge, cause I didn't have had the change to use lex
outside of university. At university I just was capable to finish a
little compiler in about 1 week of hard work (using lex, yacc, ox, and
i-burg). (actually I am still studying at the Technical University of
Vienna)
So I won't dare to say anything against your base of knowledge since my
knowledge isn't able to compete with yours.
So I only was woundering why you did what you did.
I think my questions for this topic are answered yet.

kind regards, +43-676-4708155
Michael Moerz Systemengineer +43-1-718-98-80
CUBiT www.cubit.at


On Thu, 9 Dec 1999, Alan Robertson wrote:

> Michael Moerz wrote:
> >
> > Hi!
> >
> > I have read config.c and I wounder why flex and yacc are not used for
> > parse the configuration-files. I suppose that writing that stuff in flex
> > would not only make the source better readable, but also easier to modify
> > and extendable.
>
> Because it is about 100 times overkill, and the lex/yacc code would not be much
> smaller (in source). Also, there are lots of different gotchas in using lex and
> yacc (like the inability to handle more than one grammar in a given program)
> that I didn't want to try and overcome with in this situation. Additionally,
> given the simple syntax of the config file, it would actually be *less* readily
> extended in many useful ways than the current code.
>
> I wrote the current code in about an hour. Lex/Yacc would have probably taken
> longer, and been impossible to add more file types to parse, and the resulting
> code would have been MUCH bigger in object form, and similar in source size.
>
> Other than that, I didn't have any particular reason :-)
>
> Readability in something like this depends on knowing the "patterns" of lexical
> analysis in C. If you're familiar with the normal patterns for this, the code
> will be readable. If you're only familiar with using lex and yacc, it probably
> won't seem clear to you.
>
> I have written several dozen parsers of varying degrees of sophistication, and
> many of them used lex and yacc. My engineering judgment was that this structure
> was cleaner and better suited to our needs.
>
> I admit that the code for parsing authkeys needs help. I didn't modify that
> part of the code enough after I got it. Laziness on my part, I guess.
>
> As we go forward and try and build a more sophisticated (multi-node) cluster, it
> *might* be the case that our situation might change and rewriting it might be
> better than adding a little to it.
>
> -- Alan Robertson
> alanr@bell-labs.com
>
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev@lists.tummy.com
> http://lists.tummy.com/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
>
Implementation of configuration-api [ In reply to ]
Another valid reason is that Lex/Yacc may not be installed on a system it
could be Flex/Bison only.

By doing C code it will also be more portable amongst systems (since I am
currently porting to FreeBSD).

Matt Soffen
Applications Developer
http://www.iso-ne.com/
==============================================
Boss - "My boss says we need some eunuch programmers."
Dilbert - "I think he means UNIX and I already know UNIX."
Boss - "Well, if the company nurse comes by, tell her I said
never mind."
- Dilbert -
==============================================


> -----Original Message-----
> From: Michael Moerz [SMTP:mike@cubit.at]
> Sent: Friday, December 10, 1999 8:18 AM
> To: linux-ha-dev@lists.tummy.com
> Cc: Alan R
> Subject: Re: [Linux-ha-dev] Implementation of configuration-api
>
> Hi!
>
> I admire your knowledge, cause I didn't have had the change to use lex
> outside of university. At university I just was capable to finish a
> little compiler in about 1 week of hard work (using lex, yacc, ox, and
> i-burg). (actually I am still studying at the Technical University of
> Vienna)
> So I won't dare to say anything against your base of knowledge since my
> knowledge isn't able to compete with yours.
> So I only was woundering why you did what you did.
> I think my questions for this topic are answered yet.
>
> kind regards, +43-676-4708155
> Michael Moerz Systemengineer +43-1-718-98-80
> CUBiT www.cubit.at
>
>
> On Thu, 9 Dec 1999, Alan Robertson wrote:
>
> > Michael Moerz wrote:
> > >
> > > Hi!
> > >
> > > I have read config.c and I wounder why flex and yacc are not used for
> > > parse the configuration-files. I suppose that writing that stuff in
> flex
> > > would not only make the source better readable, but also easier to
> modify
> > > and extendable.
> >
> > Because it is about 100 times overkill, and the lex/yacc code would not
> be much
> > smaller (in source). Also, there are lots of different gotchas in using
> lex and
> > yacc (like the inability to handle more than one grammar in a given
> program)
> > that I didn't want to try and overcome with in this situation.
> Additionally,
> > given the simple syntax of the config file, it would actually be *less*
> readily
> > extended in many useful ways than the current code.
> >
> > I wrote the current code in about an hour. Lex/Yacc would have probably
> taken
> > longer, and been impossible to add more file types to parse, and the
> resulting
> > code would have been MUCH bigger in object form, and similar in source
> size.
> >
> > Other than that, I didn't have any particular reason :-)
> >
> > Readability in something like this depends on knowing the "patterns" of
> lexical
> > analysis in C. If you're familiar with the normal patterns for this,
> the code
> > will be readable. If you're only familiar with using lex and yacc, it
> probably
> > won't seem clear to you.
> >
> > I have written several dozen parsers of varying degrees of
> sophistication, and
> > many of them used lex and yacc. My engineering judgment was that this
> structure
> > was cleaner and better suited to our needs.
> >
> > I admit that the code for parsing authkeys needs help. I didn't modify
> that
> > part of the code enough after I got it. Laziness on my part, I guess.
> >
> > As we go forward and try and build a more sophisticated (multi-node)
> cluster, it
> > *might* be the case that our situation might change and rewriting it
> might be
> > better than adding a little to it.
> >
> > -- Alan Robertson
> > alanr@bell-labs.com
> >
> > _______________________________________________________
> > Linux-HA-Dev: Linux-HA-Dev@lists.tummy.com
> > http://lists.tummy.com/mailman/listinfo/linux-ha-dev
> > Home Page: http://linux-ha.org/
> >
>
>
>
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev@lists.tummy.com
> http://lists.tummy.com/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
Implementation of configuration-api [ In reply to ]
Michael Moerz wrote:
>
> Hi!
>
> I admire your knowledge, cause I didn't have had the change to use lex
> outside of university. At university I just was capable to finish a
> little compiler in about 1 week of hard work (using lex, yacc, ox, and
> i-burg). (actually I am still studying at the Technical University of
> Vienna)
> So I won't dare to say anything against your base of knowledge since my
> knowledge isn't able to compete with yours.
> So I only was woundering why you did what you did.
> I think my questions for this topic are answered yet.
>
> kind regards, +43-676-4708155
> Michael Moerz Systemengineer +43-1-718-98-80
> CUBiT www.cubit.at

My apologies for communicating in a harsh and defensive way. I have done a lot
of these things, and I can write them quickly and reliably in this style (and a
few others). They are reliable and work well, but aren't as pretty in syntax,
or as expressive as an LALR(1) grammar is.

On the other hand, I didn't think I needed that, and it would effect the
complexity of other tools like GUI configuration tools, etc.

Regarding the "base of knowledge" -- That just comes from being an "old fart" in
computing. I've been programming a long time (~30 years). My specialty in my
master's program was compilers. I like them.

In the past, most of my "side projects" were compiler related. Now, in the open
source world, other people have to put up with them too ;-)

-- Alan Robertson
alanr@bell-labs.com