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 TAA28258; Wed, 11 Sep 2002 19:08:37 +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 TAA17032 for ; Wed, 11 Sep 2002 19:08:34 +0200 (MET DST) Received: from viola.sinor.ru (viola.sinor.ru [217.70.106.9]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g8BH8W910583 for ; Wed, 11 Sep 2002 19:08:33 +0200 (MET DST) Received: from sibnet.ru (tlg5-ppp45.sibnet.ru [217.70.116.45]) by viola.sinor.ru (8.12.3/8.12.3) with ESMTP id g8BH8Qp1005127 for ; Thu, 12 Sep 2002 00:08:27 +0700 Received: by sibnet.ru id m17pApm-001EocC; Wed, 11 Sep 2002 23:59:22 +0700 (NOVST) Date: Wed, 11 Sep 2002 23:59:22 +0700 From: Max Kirillov To: caml-list@inria.fr Subject: [Caml-list] camlp4 -- troubles with printer Message-ID: <20020911235922.A633@max.home> Mail-Followup-To: caml-list@inria.fr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AqsLC8rIMeq19msA" Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Sender: Max Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --AqsLC8rIMeq19msA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello. Let's consider the attached file. It splits a file at words "WHERE", reverses the order of the pieces, and concat them back. Trying to print the result, I got an error: : $cat test.ml : let _ = print_string "1\n"; flush stdout : WHERE : let _ = print_string "2\n"; flush stdout : $camlp4o ./syntax1.cmo pr_o.cmo test.ml : let _ = print_string "1\n"; flush stdout : WHERE : let _ = print_string "2\n"; flush stdoutUncaught exception: End_of_file But, the code works: : $ocamlc -pp "camlp4o ./syntax1.cmo" test.ml : $./a.out : 2 : 1 More complex code works as well, but the printing always fails. I suspect this is due to 'loc' values are not accendind. The error is displayed at ocaml-3.06 as well as ocaml-3.04 Max. --AqsLC8rIMeq19msA Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="syntax1.ml" (* ocamlc -pp "camlp4o pa_extend.cmo q_MLast.cmo" -I +camlp4 -c syntax1.ml *) open Pcaml;; EXTEND str_item: LAST [[ EOI -> assert false | "WHERE" -> <:str_item< $lid:"wHERE"$ >> ]]; END;; (* generally, this splits a list, then reverses the large parts and concat them back *) let wrap f x = let split pred l = (* cound not found it *) let rec s1 rl add argl = try let e = List.hd argl and tl = List.tl argl in match (pred e,add,rl) with (false,true,rl) -> s1 ([e]::rl) false tl | (false,false,re::rl') -> s1 ((e::re)::rl') false tl | (false,false,[]) -> assert false | (true,false,rl) -> s1 rl true tl | (true,true,rl) -> s1 ([]::rl) true tl with Failure "hd" | Failure "tl" -> rl in s1 [] true l in let wrapV (l,fl) = let m1 = function (<:str_item< $lid:"wHERE"$ >>,_) -> true | _ -> false in let (&>) f1 f2 x = f2 (f1 x) in let res = (split m1 &> List.map List.rev &> List.concat) l in (res,fl) in wrapV (f x);; Pcaml.parse_implem := wrap (!Pcaml.parse_implem);; --AqsLC8rIMeq19msA-- ------------------- 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