[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Parsing DNS zonefiles

Berger, Daniel

7/14/2005 6:20:00 PM

> -----Original Message-----
> From: why the lucky stiff [mailto:ruby-talk@whytheluckystiff.net]
> Sent: Thursday, July 14, 2005 11:28 AM
> To: ruby-talk ML
> Subject: Parsing DNS zonefiles
>
>
> Anyone have a parser for BIND8/9 zonefiles?
>
> _why

I don't see anything in Ruby land, but there's the Perl module
DNS-ZoneParse, if you feel like porting.

http://search.cpan.org/~simonflk/DNS-ZoneParse-0.95/lib/DNS/Zo...

The author appears to be using regular expressions rather than a
bonafide parser, however.

Regards,

Dan


5 Answers

Dennis Roberts

7/14/2005 7:58:00 PM

0

Dan could you explain the difference between using regular expressions
and a bonafide parser?

On 7/14/05, Berger, Daniel <Daniel.Berger@qwest.com> wrote:
> > -----Original Message-----
> > From: why the lucky stiff [mailto:ruby-talk@whytheluckystiff.net]
> > Sent: Thursday, July 14, 2005 11:28 AM
> > To: ruby-talk ML
> > Subject: Parsing DNS zonefiles
> >
> >
> > Anyone have a parser for BIND8/9 zonefiles?
> >
> > _why
>
> I don't see anything in Ruby land, but there's the Perl module
> DNS-ZoneParse, if you feel like porting.
>
> http://search.cpan.org/~simonflk/DNS-ZoneParse-0.95/lib/DNS/Zo...
>
> The author appears to be using regular expressions rather than a
> bonafide parser, however.
>
> Regards,
>
> Dan
>
>


James Gray

7/14/2005 8:17:00 PM

0

On Jul 14, 2005, at 2:57 PM, Dennis Roberts wrote:

> Dan could you explain the difference between using regular expressions
> and a bonafide parser?

It's usually a measure of how robust the parsing is. I love Regexp
as much as the next guy, but when you expand them to handle parsing
they tend to get a little shaky. It's often easy to come up with
edge cases they don't handle well.

There are no absolutes, of course. I've seen good Regexp based
parsers and non-Regexp based parsers that were poor. However, it
often holds that non-Regexp parsers are more robust.

James Edward Gray II


why the lucky stiff

7/14/2005 8:28:00 PM

0

Dennis Roberts wrote:

>Dan could you explain the difference between using regular expressions
>and a bonafide parser?
>
>
He's just distinguishing between a parser which obeys an overall grammar
and a parser made of regexps (little grammars).

Ruby's parser, for instance, leverages a parser generator (yacc) which
is given the rules used to parse Ruby source code.

However, Regexps are often used in conjunction with Racc, a parser
generator for Ruby. So Regexps aren't always a bad thing, and in fact
they can be used to add great flexibility (such as in feedparser.org),
they just tend to leave lots of holes in the overall soundness of the
parser.

_why


Dennis Roberts

7/15/2005 5:32:00 AM

0

Ahh. Makes sense. Thanks for the clarification.

On 7/14/05, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:
> Dennis Roberts wrote:
>
> >Dan could you explain the difference between using regular expressions
> >and a bonafide parser?
> >
> >
> He's just distinguishing between a parser which obeys an overall grammar
> and a parser made of regexps (little grammars).
>
> Ruby's parser, for instance, leverages a parser generator (yacc) which
> is given the rules used to parse Ruby source code.
>
> However, Regexps are often used in conjunction with Racc, a parser
> generator for Ruby. So Regexps aren't always a bad thing, and in fact
> they can be used to add great flexibility (such as in feedparser.org),
> they just tend to leave lots of holes in the overall soundness of the
> parser.
>
> _why
>
>


William Morgan

7/18/2005 12:18:00 AM

0

Excerpts from Dennis Roberts's mail of 14 Jul 2005 (EDT):
> Dan could you explain the difference between using regular expressions
> and a bonafide parser?

In addition to what others have said, if you have to handle
ungrammatical files on a regular basis (I do---xml files), I've found it
typically easier to write regexp parsers that are robust to
ungrammatical input than to try and force a parser to be robust.

Also, if you just want one particular bit of information, regexps can be
a one-line alternative to a many-line grammar.

(There are also theoretical distinctions between the two (parser
generators win) but I don't find them all that commonplace in practice.)

--
William <wmorgan-ruby-talk@masanjin.net>