From: "David Allsopp" <dra-news@metastack.com>
To: "OCaml List" <caml-list@yquem.inria.fr>
Subject: Fairly dumb ocamlyacc question
Date: Tue, 24 Oct 2006 17:04:25 -0400 [thread overview]
Message-ID: <003401c6f7b0$01f9ca10$5a878640@countertenor> (raw)
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
next reply other threads:[~2006-10-24 21:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-24 21:04 David Allsopp [this message]
2006-10-24 21:40 ` [Caml-list] " Yann Régis-Gianas
2006-10-24 22:32 ` skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003401c6f7b0$01f9ca10$5a878640@countertenor' \
--to=dra-news@metastack.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox