Browse thread
[Caml-list] ocamllex, regular expression syntax
[
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: | -- (:) |
| From: | Pierre Weis <pierre.weis@i...> |
| Subject: | Re: [Caml-list] ocamllex, regular expression syntax |
Hi,
[...]
> 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.
Regards,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners