[
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: | Jake Donham <jake@d...> |
| Subject: | Re: [Caml-list] camlp4 grammar and LIST1 |
On Tue, Mar 10, 2009 at 3:07 PM, Joel Reymont <joelr1@gmail.com> wrote: > I have it like this at the moment. Are you saying it won't work? Here's an example of what I'm talking about: open Camlp4.PreCast let bar = Gram.Entry.mk "bar" let baz = Gram.Entry.mk "baz" let bar_or_baz = Gram.Entry.mk "bar_or_baz" ;; EXTEND Gram bar : [[ LIST0 "quux"; "bar" -> () ]]; baz : [[ LIST0 "quux"; "baz" -> () ]]; bar_or_baz : [[ bar | baz ]]; END ;; Gram.parse_string bar_or_baz Loc.ghost "quux quux baz" The given string does not parse because we've already committed to the bar branch. However, several variations I tried did not show this behavior (e.g. only one quux in the string). I think there are some special cases, although they are not documented anywhere I have found. An approach that works for me is to think "recursive descent" and always give rules that check at least one token before branching to another rule. Jake