On Wed, 9 Sep 1998 17:17:02 Glynn Clements wrote:
> Niels Hald Pedersen wrote:
>
> > > The fastest way to read textual data is to write your own scanner
> > > using lex/flex, and to ensure that it doesn't need to back-up (see the
> > > flex info file for what backing-up is and how to avoid it).
> >
> > Just adding that it may (or may not) be a good idea to use lex/flex in
> > combination with bison/yacc, doing the high level parsing with the
> > latter.
>
> For parsing more complex formats, yacc is (IMHO) the way to go.
>
> However, in this particular case, the input format has a flat (i.e.
> non-recursive) syntax, so I think that using yacc would be overkill.
How about using regexps? They probably would not be quite as fast as a compiled
parser, but they might be fast enough. There are several libraries available
including the GNU stuff that has been folded into libc.
The fastest compilers, gcc being one of them, use hand coded parsers. If the
automatically generate parsers aren't fast enough this approach might be the
only alternative.
Since what is fast enough is atleast some what a matter of perception if
application requirements will permit "chunking" the input then the first chunk
can be presented to the user while the parsing continues. Preprocessing the
input into a binary file structure could remove the parsing from the user's time
window completely. If the same input file is accessed multiple times the binary
file would be an even bigger win.
David Ross
[EMAIL PROTECTED]
Toad Technologies
"I'll be good! I will, I will !"