caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: Caml List <caml-list@pauillac.inria.fr>
Subject: Re: [Caml-list] debugging an ocamlyacc parser
Date: Tue, 23 Oct 2001 09:51:11 +0200 (CEST)	[thread overview]
Message-ID: <15317.8559.766412.887529@gargle.gargle.HOWL> (raw)
In-Reply-To: <20011023101442.B17138@team.ph.inter.net>

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


  parent reply	other threads:[~2001-10-23  7:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-23  2:14 Rafael 'Dido' Sevilla
2001-10-23  5:42 ` Mattias Waldau
2001-10-23  7:51 ` Hendrik Tews [this message]
2001-10-24 14:53 ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15317.8559.766412.887529@gargle.gargle.HOWL \
    --to=tews@tcs.inf.tu-dresden.de \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).