From: dengping zhu <zhudp@cs.bu.edu>
To: caml-list@inria.fr
Subject: [Caml-list] help me with infix in ocaml
Date: Fri, 24 May 2002 20:41:51 -0400 (EDT) [thread overview]
Message-ID: <Pine.SOL.4.20.0205242028080.23416-100000@csa.bu.edu> (raw)
Hi, all, please help me if you can!
Now I am converting a bunch of code from sml to ocaml. I met a problem
with infix in ocaml.
According to the example from camlp4, I got the following code:
let gram = Grammar.create (Plexer.make());;
let expr = Grammar.Entry.create gram "expr";;
EXTEND
expr:
[ "1" LEFTA [] | "2" LEFTA []];
END;;
let add_infix lev op =
EXTEND
GLOBAL: expr;
expr: LEVEL $lev$
[ [ x = expr; $op$; y = expr -> <:expr< $lid:op$ $x$ $y$ >> ] ]
;
END;;
---------------
After I compile the code in ocaml by
# #use "foo.ml";;
I can add an infix, for example
# add_infix "1" "op1";;
But till now, how can I use this infix "op1"?
Actually, I have the following code in sml, I can not figure out how to
write it in ocaml.
...
infix 2 --
...
fun (p -- q) (pos, ts) =
let
val (x, posx, pos, ts) = p (pos, ts)
val (y, posy, pos, ts) = q x (pos, ts)
in
(y, Pos.union (posx, posy), pos, ts)
end
Thanks a lot!
Dengping
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2002-05-25 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-25 0:41 dengping zhu [this message]
2002-05-27 9:03 ` Daniel de Rauglaudre
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=Pine.SOL.4.20.0205242028080.23416-100000@csa.bu.edu \
--to=zhudp@cs.bu.edu \
--cc=caml-list@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