Re: scanning and parsing short strings

From: Francois Rouaix (Francois.Rouaix@inria.fr)
Date: Thu Jul 17 1997 - 18:22:33 MET DST


Message-Id: <199707171622.SAA05148@madiran.inria.fr>
From: Francois Rouaix <Francois.Rouaix@inria.fr>
To: Christian Lindig <lindig@ips.cs.tu-bs.de>
Subject: Re: scanning and parsing short strings
Date: Thu, 17 Jul 1997 18:22:33 +0200

> many applications rely on protocols which they must parse. This can
> be either done ad hoc using regular expressions or scanner/parser
> generated by Camllex/yacc. Which method is advisable when the scanned
> items are relative short strings (< 100 Bytes)?
[...]
> The background of my question: I like to implement a CGI library.
> I already took a look at the MMM code which uses a mixed approach.

I can't give performance comparisons, but here are some personal appreciations
on the various solutions.
* regular expressions dont scale
It's probably all right for CGI headers because these are small one-line
inputs, and their syntax is essentially trivial, but then it's also error
prone (you rarely write the correct pattern at once). Then, libstr also
requires building custom binaries which make bigger applications (at least
with the bytecode compiler).
* camllex is easy. Besides lexical analysis, it can also handle simple
parsing strategies, such as recursive descent
* yacc (and therefore camlyacc) is a pain, and will always be. Moreover,
error handling is not that easy.

Also, streams and parsers are a possible alternative to camllex/yacc, although
here you will loose some speed.

--f



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET