Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2001-10-23 (05:42)
From: Mattias Waldau <mattias.waldau@a...>
Subject: RE: [Caml-list] debugging an ocamlyacc parser
I normally test the lexer and the parser separately.

The lexer is easy to test using a function like:

  let lexbuf = Lexing.from_channel file_channel in
  let result = ref [] in
    while true do
      let next_token = Dtd_lexer.token lexbuf in
      result := next_token :: !result;
      if debug_lexer then Dtd_types.print next_token;
      if next_token = Dtd_types.EOF then raise Not_found
    List.rev (!result)
  with Not_found -> List.rev (!result)

For debugging the parser I set the -v flag to ocamlyacc and look at the
.parser file


> -----Original Message-----
> From:
> []On Behalf Of Rafael 'Dido'
> Sevilla
> Sent: Tuesday, October 23, 2001 4:15 AM
> To: Caml List
> Subject: [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).
> --
> Rafael R. Sevilla <>   +63(2)   8177746
> ext. 8311
> Programmer, Inter.Net Philippines                +63(917) 4458925
>                OpenPGP Key ID:
> 0x5CDA17D8
> -------------------
> Bug reports:  FAQ:
To unsubscribe, mail  Archives:

Bug reports:  FAQ:
To unsubscribe, mail  Archives: