[
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: | Yann_Régis-Gianas <yann.regisgianas@g...> |
| Subject: | Re: [Caml-list] Fairly dumb ocamlyacc question |
Hello,
Have you tried menhir :
http://pauillac.inria.fr/~fpottier/menhir/menhir.html.en ?
Menhir generates an explanation of your conflicts and is 90%
compatible with ocamlyacc.
Hope this helps,
--
Yann R.-G.
On 10/24/06, David Allsopp <dra-news@metastack.com> wrote:
> This should be obvious, but I can't quite solve it!
>
> If I use the following ocamlyacc script:
>
> ------------
> %token BEFORE_KWD AFTER_KWD
> %token FAILS_KWD
>
> %token <int> WEEKDAY
> %token <string> NAME
>
> %type <unit> top
> %start top
> %%
>
> top:
> WEEKDAY AFTER_KWD NAME BEFORE_KWD NAME FAILS_KWD top {()}
> | WEEKDAY relative NAME {()}
> ;
>
> relative:
> BEFORE_KWD {()}
> | AFTER_KWD {()}
> ;
> ------------
>
> Then I get a shift/reduce having parsed WEEKDAY AFTER_KWD... the parser
> can't figure out what to do if it sees NAME. This problem can be made to
> disappear by expanding the relative rules to give:
>
> top:
> WEEKDAY AFTER_KWD NAME BEFORE_KWD NAME FAILS_KWD top {()}
> | WEEKDAY AFTER_KWD NAME {()}
> | WEEKDAY BEFORE_KWD NAME {()}
> ;
>
> I've tried a couple of tricks with %prec but can't get the parser to come
> out the same way with the first rule... please could someone put me out of
> my misery!!
>
> Thanks,
>
>
> David
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Yann