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 JAA22621; Tue, 23 Oct 2001 09:51:23 +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 JAA22955 for ; Tue, 23 Oct 2001 09:51:22 +0200 (MET DST) Received: from tcs.inf.tu-dresden.de (tcs.inf.tu-dresden.de [141.76.75.101]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f9N7pMT04839 for ; Tue, 23 Oct 2001 09:51:22 +0200 (MET DST) Received: from ithif51 (ithif51 [141.76.75.51]) by tcs.inf.tu-dresden.de (8.12.0.Beta7/8.12.0.Beta7) with ESMTP id f9N7pC49022000 for ; Tue, 23 Oct 2001 09:51:12 +0200 (MET DST) Received: from tews by ithif51 with local (Exim 3.12 #1 (Debian)) id 15vwL9-0003Fc-00 for ; Tue, 23 Oct 2001 09:51:11 +0200 From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15317.8559.766412.887529@gargle.gargle.HOWL> Date: Tue, 23 Oct 2001 09:51:11 +0200 (CEST) To: Caml List Subject: Re: [Caml-list] debugging an ocamlyacc parser In-Reply-To: <20011023101442.B17138@team.ph.inter.net> References: <20011023101442.B17138@team.ph.inter.net> X-Mailer: VM 6.75 under Emacs 20.7.2 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, Rafael 'Dido' Sevilla writes: Date: Tue, 23 Oct 2001 10:14:42 +0800 Subject: [Caml-list] debugging an ocamlyacc parser I'm just wondering if there's a debug mode available for ocamlyacc-generated parsers, like the debugging mode that Bison uses when you do a #define YYDEBUG, printing out all the states the parser I was also missing the YYDEBUG. My workaround looks as follows: In the header of grammar.mly: let d s = if debug_level _DEBUG_PARSER then begin prerr_string ("REDUCE " ^ s ^ "\n"); flush stderr end;; a typical rule looks like signaturetype: TYPE ID { d "signaturetype"; do_sig_type_decl $2; } ; The lexer uses the same schema: let d s = if debug_level _DEBUG_LEXER then begin prerr_string ("SHIFT " ^ s ^ "\n"); flush stderr end and | '=' { d "Equal"; EQUAL } _DEBUG_PARSER and _DEBUG_LEXER are constants and the return value of the debug_level function can be influenced via a command line switch. Bye, Hendrik ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr