Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] help me with infix in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: dengping zhu <zhudp@c...>
Subject: [Caml-list] help me with infix in ocaml
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";;

      [ "1" LEFTA [] | "2" LEFTA []];

let add_infix lev op =
           GLOBAL: expr;
           expr: LEVEL $lev$
           [ [ x = expr; $op$; y = expr -> <:expr< $lid:op$ $x$ $y$ >> ] ]


After I compile the code in ocaml by 
# #use "";;

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) =
		val (x, posx, pos, ts) = p (pos, ts)
		val (y, posy, pos, ts) = q x (pos, ts)
		(y, Pos.union (posx, posy), pos, ts)

Thanks a lot!
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: