Ethereal-users: Re: [ethereal-users] Some Questions

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Fri, 31 Mar 2000 11:18:43 -0600
On Fri, Mar 31, 2000 at 04:49:07AM -0600, Schneider Ralf wrote:
> 4.  Is it really necessary or even usefull to use lex/Yacc to filter?? From
> other ( unskilled as far as I think because of
>      all the pronblems they had ) guys and a project I remember that the
> code exploded when using lex/Yacc. It was
>      translated into C that was NOT understandable anymore. I havn't looked
> at the ethereal code nor I think that I will
>      understand it now -- so it's a more academical question to you.

It's necessary to use a scanner-generator and a parser-generator
for filters. One could write the C code themselves, but the advantage
of high-level tools as that you describe the problem set in a language
suited for that task. Computer scientists figured out generic ways
to produce scanners and parsers years ago; that's why these tools exist.
There's no reason to re-invent the wheel and try to hand-code a scanner
or a parser in C.

It doesn't matter if the C code produced by
the scanner-generator or the parser-generator is not understandble. The
developer should not be reading the generated C code anyway. If he has to read
the generated C code, then his high-level representation (lex file or
yacc file, in this case) is wrong anyway.

That said, I'm currently re-writing the display filter routines. They'll
go in after the version 0.8.5, which should be out next week. I'm still
using lex to generate the scanner, but I've switched to using lemon
to produce the grammar, since it has a nice feature of keeping track of
non-terminal tokens that are generated during a parse, and will easily
let me free that memory, even after a failed parse. This makes it
easier to write a parser that doesn't leak memory, which is essential
in a long-running GUI program that could possibly run the parser over
and over again. The same is possible in yacc (and I have done that in
the current yacc grammar for Ethereal's display filter routines),
but its just harder.

--gilbert