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] Possible bug in the lexer?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-08-10 (08:40)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Possible bug in the lexer?

On Fri, Aug 10, 2001 at 05:51:28AM +0100, Ceri Storey wrote:

> I think I've discovered wierd bug in ocaml's lexer. it seems that in
> ocaml 3.01, and 3.02, (and camlp4 original syntax) the following will not 
> parse:
> parser [< ' '"' >] -> ();;

While reading the input, the lexer, instead of reading the token
"quote" and the token "character double-quote", reads the token
"character space" and then the double quote...

It is a design bug, actually. In streams and parsers, the quote is a
token used to introduce a "terminal". In Caml Light (before OCaml),
there was no confusion because the token "character" was enclosed by

Since OCaml, the characters have been enclosed by right quotes (what
is more usual). At that time, we should have changed the token
introducing "terminals" in streams and parsers, we could have choosen
backquotes, for example.

But we forgot. It is the reason of this problem. This is fixed in
revised syntax of Camlp4.

In normal syntax, if you have to specify a "terminal" in a parser, you
must be sure that there is no simple quote 2 characters after your
simple quote.

Write your example as:
   parser [< ''"' >] -> ();;
   parser [< '  '"' >] -> ();;

And write:
   parser [< ' ('"' | 'a') >] -> ();;
   parser [< '('"' | 'a') >] -> ();;

Sorry for the inconvenience... due to historical reasons, what is often
the case...

Bug reports:  FAQ:
To unsubscribe, mail  Archives: