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 KAA31310; Fri, 30 Aug 2002 10:21:19 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA31472 for ; Fri, 30 Aug 2002 10:21:19 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g7U8LID08183 for ; Fri, 30 Aug 2002 10:21:18 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id KAA09318 for caml-list@inria.fr; Fri, 30 Aug 2002 10:21:18 +0200 Date: Fri, 30 Aug 2002 10:21:18 +0200 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] camlp4: pretty printing not to a file Message-ID: <20020830102118.B8876@verdot.inria.fr> References: <5B049D08-BB80-11D6-9EB3-00039375801A@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <5B049D08-BB80-11D6-9EB3-00039375801A@yahoo.com>; from jehenrik@yahoo.com on Thu, Aug 29, 2002 at 02:51:41PM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Thu, Aug 29, 2002 at 02:51:41PM -0400, jehenrik wrote: > Also it seems like there might be a way to take the parsing offsets > and look back in the original pre-parsed string to get the real > source snippet. let getsource fname (bp, ep) = let ic = open_in_bin fname in let s = String.create (ep - bp) in seek_in ic bp; really_input ic s 0 (ep - bp); close_in ic; s > EXTEND > expr: LEVEL "expr1" > [ LEFTA [ "REFLECTLIST"; hd = expr; "::"; tl = expr -> > map_expr reflect_arg <:expr< [$hd$::$tl$] >> > ] ]; > END;; > > let r = Grammar.Entry.parse expr (Stream.of_string "REFLECTLIST > [1;3;5;11]");; Input: REFLECTLIST [1;3;5;11] The rule recognizes the keyword REFLECTLIST. Then the rule symbol "hd = expr" recognizes the expr "[1;3;5;11]" Then the rule expects a "::". There is no "::". Therefore: syntax error. > let r = Grammar.Entry.parse expr (Stream.of_string "REFLECTLIST > 1::3::5::11::[]\ > ");; Idem. The symbol "hd = expr" recognizes the expr "1::3::5::11::[]". There is no "::" following it. Therefore syntax error again. > Can anyone please enlighten me? And why not just: EXTEND expr: LEVEL "expr1" [ LEFTA [ "REFLECTLIST"; e = expr -> map_expr reflect_arg e ] ]; END;; -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- 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