From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10559; Mon, 20 Sep 2004 10:57:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA10618 for ; Mon, 20 Sep 2004 10:57:46 +0200 (MET DST) Received: from oceanite.ens-lyon.fr (oceanite.ens-lyon.fr [140.77.1.22]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8K8vkFB012565 for ; Mon, 20 Sep 2004 10:57:46 +0200 Received: from localhost (oceanite.ens-lyon.fr [127.0.0.1]) by oceanite.ens-lyon.fr (Postfix) with ESMTP id 53B69320637 for ; Mon, 20 Sep 2004 10:57:17 +0200 (CEST) Received: from oceanite.ens-lyon.fr ([127.0.0.1]) by localhost (oceanite [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30119-06 for ; Mon, 20 Sep 2004 10:57:17 +0200 (CEST) Received: from localhost.localdomain (ermitage.cri2000.ens-lyon.fr [140.77.13.63]) by oceanite.ens-lyon.fr (Postfix) with SMTP id 1CE1C320418 for ; Mon, 20 Sep 2004 10:57:17 +0200 (CEST) Date: Mon, 20 Sep 2004 10:52:39 +0200 From: Damien Pous To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Calling parser from inside a parser rule Message-Id: <20040920105239.0c00bd5d@localhost.localdomain> In-Reply-To: References: X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ens-lyon.fr X-Miltered: at concorde with ID 414E9B8A.00A by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 ens-lyon:01 caml-list:01 arf:01 arf:01 toto:01 cyclic:01 2004:99 token:01 token:01 rec:01 sep:01 match:02 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk hi, why don't you recurse before the parser level ? lexer.mll: << { type token = [`Print | `Arf | `Eof] } let blank = [' ' '\r' '\t' '\n']* let word = [ 'a'-'z' '.' ]* rule token = parse | blank { token lexbuf } | "#include" blank '"' (word as s) '"' { `Include s } | "print" { `Print } | "arf" { `Arf } (* ... *) | eof { `Eof } >> reclexer.mll << let token lexbuf: unit -> Lexer.token = let acc = ref [lexbuf] in let rec aux () = match !acc with | [] -> `Eof | (x::q) as l -> match Lexer.token x with | `Include s -> acc := (Lexing.from_channel (open_in s))::l; aux() | `Eof -> acc := q; aux() | #Lexer.token as t -> t in aux >> let t = token (Lexing.from_channel (open_in "toto"));; t();; t();; ... of course you have to handle cyclic includes... damien On Sun, 19 Sep 2004 08:50:42 -0700 James Lamanna wrote: > Essentially. > I want to be able to recurse into my parser. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners