Browse thread
[Caml-list] debugging an ocamlyacc parser
-
Rafael 'Dido' Sevilla
- Mattias Waldau
- Hendrik Tews
- Xavier Leroy
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2001-10-23 (07:51) |
From: | Hendrik Tews <tews@t...> |
Subject: | Re: [Caml-list] debugging an ocamlyacc parser |
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