caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Fairly dumb ocamlyacc question
@ 2006-10-24 21:04 David Allsopp
  2006-10-24 21:40 ` [Caml-list] " Yann Régis-Gianas
  2006-10-24 22:32 ` skaller
  0 siblings, 2 replies; 3+ messages in thread
From: David Allsopp @ 2006-10-24 21:04 UTC (permalink / raw)
  To: OCaml List

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-24 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-24 21:04 Fairly dumb ocamlyacc question David Allsopp
2006-10-24 21:40 ` [Caml-list] " Yann Régis-Gianas
2006-10-24 22:32 ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).