English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] ocamllex+ocamlyacc and not parsing properly
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-08-08 (06:47)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] ocamllex+ocamlyacc and not parsing properly
On 8/8/05, Jon Harrop <jon@ffconsultancy.com> wrote:
> On Monday 08 August 2005 06:03, Jonathan Roewen wrote:
> > BTW: A tutorial on these sorts of things (i.e. something a bit more
> > complicated than the calculator example) would be great to have as a
> > resource.
> Given that the grammar is tiny and the lexer has almost as much OCaml code as
> lexing rules, I think this is a good candidate for not using lexing and
> parsing at all. If you wrote this as an OCaml function, how long would it be?

I have no idea, and don't really want to think about it either.
Perhaps someone could come up with a fancy regex using the Str module
that could do it in a single line, although you'd still need to
generate the types with some big function.

The lexer and parser are straightforward and simple, and they work
(now -- using a ref). Not to mention clear to read :) I think a giant
regex and type generating function would be less clear and
understandable. Sure it'll prolly add about 10Kb using lexer+parser,
but I don't care too much about that.