* [Caml-list] help me with infix in ocaml
@ 2002-05-25 0:41 dengping zhu
2002-05-27 9:03 ` Daniel de Rauglaudre
0 siblings, 1 reply; 2+ messages in thread
From: dengping zhu @ 2002-05-25 0:41 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-05-27 9:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-25 0:41 [Caml-list] help me with infix in ocaml dengping zhu
2002-05-27 9:03 ` Daniel de Rauglaudre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox