caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* scanning and parsing short strings
@ 1997-07-10 14:42 Christian Lindig
  1997-07-17 16:22 ` Francois Rouaix
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Lindig @ 1997-07-10 14:42 UTC (permalink / raw)
  To: caml-list


[sorry - no french version]

Dear Caml enthusiasts,

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)? In general I would
prefer to use Camllex/yacc specifications in order not distribute the
different parsers over the whole application. On the other hand start-up
time of the scanner/lexer may be too high when used for small strings
(Lexing.from_string). Any advice?

The background of my question: I like to implement a CGI library. There
are many headers that are passed to a CGI application that need to
be parsed. I already took a look at the MMM code which uses a mixed
approach. 

Christian

--                     
 Christian Lindig        
 lindig@ips.cs.tu-bs.de  
                         





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: scanning and parsing short strings
  1997-07-10 14:42 scanning and parsing short strings Christian Lindig
@ 1997-07-17 16:22 ` Francois Rouaix
  0 siblings, 0 replies; 2+ messages in thread
From: Francois Rouaix @ 1997-07-17 16:22 UTC (permalink / raw)
  To: Christian Lindig; +Cc: caml-list

> 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








^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-07-17 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-10 14:42 scanning and parsing short strings Christian Lindig
1997-07-17 16:22 ` Francois Rouaix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).