Browse thread
[Caml-list] ocamllex+ocamlyacc and not parsing properly
[
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: | 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. Jon