From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 E3AD2BBB7 for ; Fri, 28 Jul 2006 16:01:06 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6SE16WE030307 for ; Fri, 28 Jul 2006 16:01:06 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA27432 for ; Fri, 28 Jul 2006 16:01:05 +0200 (MET DST) Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.199]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6SE149O030304 for ; Fri, 28 Jul 2006 16:01:05 +0200 Received: by wx-out-0102.google.com with SMTP id s8so193079wxc for ; Fri, 28 Jul 2006 07:01:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OknIxDHAigDiR3oxEJ0wxj4g9svN3QzpiOvCLLP7g9Yzf+3/Zka5D8dGvNF5F4Ca2wPkzUVnDff1vY2S+dy7/ywMF0cy0WnFTbBUxqMFlKY6d8DZDNx7Xe8/YjnsK+qriV4wR9PoWGF7hovVJEdD8zya51f0adfYhSv2VTE7mSo= Received: by 10.70.74.2 with SMTP id w2mr2386840wxa; Fri, 28 Jul 2006 07:01:04 -0700 (PDT) Received: by 10.70.57.2 with HTTP; Fri, 28 Jul 2006 07:01:04 -0700 (PDT) Message-ID: Date: Fri, 28 Jul 2006 10:01:04 -0400 From: "Markus Mottl" To: "Jean-Marie Gaillourdet" Subject: Re: [Caml-list] Partial parsing Cc: ocaml In-Reply-To: <244C09B7-E152-4B9E-8B7E-A27AC225B5E7@gaillourdet.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <244C09B7-E152-4B9E-8B7E-A27AC225B5E7@gaillourdet.net> X-j-chkmail-Score: MSGID : 44CA18A0.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44CA18A2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44CA18A0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; markus:01 mottl:01 markus:01 mottl:01 parsing:01 lexer:01 parser:01 lexer:01 parser:01 buffer:01 threads:01 parsing:01 ocamllex:01 ocamlyacc:01 tokens:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=INFO_TLD,RCVD_BY_IP autolearn=disabled version=3.0.3 On 7/28/06, Jean-Marie Gaillourdet wrote: > You could implement such a feature on top of the existing lexer and > parser technologies by using thread. Dedicate one thread to the lexer > and parser, make the input buffer blocking and make every suitable > intermediate result available to the main thread. I'd rather not depend on extra threads for parsing. Besides of them making things complicated, in my case I also need to be able to deal with nonblocking / interruptable input functions. > But I have not much experience with continuations. And I am not sure > whether that really fits into the framework of ocamllex/ocamlyacc. I think it would work well: instead of returning a token stream, the lexer should return a stream of either matched tokens or continuations. The parser would consume the recognized tokens, or return another continuation that would continue lexing/parsing. > As Fermin Reig pointed out parser combinators provide that feature > out of the box. AFAIK, they depend on lazy evaluation. I am not sure > whether those libraries for OCaml are available to hide that or not. Sure, implementing some parser combinators might be an option, but I'm otherwise quite happy with the ease of specification and the high efficiency of ocamllex/ocamlyacc generated parsers. It's just that interrupting and resuming parsing is currently not an option. Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mottl@gmail.com