Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] debugging an ocamlyacc parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xleroy@p...>
Subject: Re: [Caml-list] debugging an ocamlyacc parser
> Well, while my current ocamlyacc parser seems to be working pretty well,
> 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
> goes through as it receives tokens from the lexer, so along with the
> generated y.output file I can see how it's working (or not working as
> the case may be).

There is such a debugging mode in the pushdown automaton used to
execute ocamlyacc parsers, but it is not easily accessible.

You need to build the "debug" version of the bytecode interpreter (cd
runtime ; make ocamlrund), then run your bytecode executable with
"ocamlrund -P myprog".

You then get a trace of shift and reduce actions; tokens read are also
printed, but in such a low-level format that it's nearly useless...

I agree this tracing facility should be made better at some point,
although printing tokens correctly is difficult in general.

- Xavier Leroy
-------------------
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