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] ocamllex, regular expression syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-05-23 (06:31)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] ocamllex, regular expression syntax

> But the regular expression syntax in the Str module looks "normal" to
> me.
> Regular expressions like this
> "[^"\\]*(\\.[^"\\]*)*"
> are not easy to read,

I suppose you did not try this, since it is not a legal regular
expression. I guess you mean


(Hence, the ``normal looking'' of those reg-exps does not imply simple,
clear, and natural syntax !)

> but with the ocamllex syntax it is even more
> difficult:
> '"'[^'"''\\']*('\\'_[^'"''\\']*)*'"'
> (and harder to write).

It is not so clear to me: the ' conventions are exactly those of the
language (hence there is no need to \\ the " symbols), the _ gets its
"normal" meaning of ``whatever'' or ``catch all case'' pattern...

> Is this just for historical reason or is there a practical reason for
> this syntax? I'm just curious...

It's just natural: you would start by giving syntax to match chars,
hence you ``naturally'' write them inside quotes following the Caml
convention. The rest of the regular expressions constructs,
succession, alternative, repetitition, range and catch-all just follow
almost automatically.


Pierre Weis

INRIA, Projet Cristal,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: