From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id DE9DCBCAE for ; Sun, 26 Jun 2005 12:12:41 +0200 (CEST) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5QACfGX004936 for ; Sun, 26 Jun 2005 12:12:41 +0200 Received: by zproxy.gmail.com with SMTP id p8so99431nzb for ; Sun, 26 Jun 2005 03:12:40 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=RaVuGWH7wRemySX5qf2my7e36eGwHI4JW60hVbeRKvIWtpW4zK+TIkHyNURDoKrodSsQkeFkf+MHbechiTLUYHN368NVk5/WP4guAv80Jy9JnczN6J/7Yf4cEREzrlnrWCv+xrht7s1AibT8AniF9dptD4c9lgVucEy6SV/GsOs= Received: by 10.36.56.16 with SMTP id e16mr3604968nza; Sun, 26 Jun 2005 03:12:40 -0700 (PDT) Received: by 10.36.79.1 with HTTP; Sun, 26 Jun 2005 03:12:40 -0700 (PDT) Message-ID: Date: Sun, 26 Jun 2005 12:12:40 +0200 From: Sen Horak Reply-To: Sen Horak To: caml-list@yquem.inria.fr Subject: Stream parser/make_lexer Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 42BE7F99.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; parser:01 lexer:01 parser:01 ocaml:01 compiler:01 lexer:01 'string:01 stdin:01 char:01 stdin:01 deprecated:01 parsers:01 ocaml:01 ocamllex:01 ocamlyacc:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: Hi, I tried building a small parser using Genlexer.make_parser and the stream parser through the camlp4 preprocessor. I'm using the ocaml compiler 3.08.1. let lexer=3Dmake_lexer ["begin";"end";...] let parse =3D parser [<'Kwd "name=3D";'String t>] -> wm#setname t | ... let istream =3D of_channel stdin let ilexer =3D lexer istream in parse ilexer The program exits with a Stream.Failure exception. The "stream builders" documentation clearly says that we are not to mix the of_* functions to build streams with <> streams - so I guess this is expected. Although I've come across some examples that use of_string to build the char stream and use the lexer on it. How then does one build a stream compatible with the stream parser connected to stdin? Also, is the make_lexer/stream parser way of building a parser deprecated? I find it a convenient way to build small parsers quickly. Or do most ocaml programmers just use ocamllex/ocamlyacc for everything? SH