From: dengping zhu <zhudp@cs.bu.edu>
To: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] infix precedence
Date: Tue, 28 May 2002 14:48:42 -0400 (EDT) [thread overview]
Message-ID: <Pine.SOL.4.20.0205281440380.4380-100000@csa.bu.edu> (raw)
In-Reply-To: <20020528203212.B21121@verdot.inria.fr>
I tried camlp4 before. I got the example from the camlp4 tutorial and
modified a little bit.
The code is as follows:
---------------------------------------------
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 it in ocaml
# #use "foo.ml";;
I can use the function 'add_infix':
# add_infix "1" "op1";;
But how can I use the infix "op1" later?
I tried to use as follows:
#let op1 x y = x + y;;
#Grammar.Entry.parse expr ( Stream.of_string "x op1 y");;
But I got an error.
Can someboday pass an example for me?
Thanks!
On Tue, 28 May 2002, Daniel de Rauglaudre wrote:
>Hi,
>
>On Tue, May 28, 2002 at 02:16:12PM -0400, dengping zhu wrote:
>
>> Hi, John, thanks for your help. Hope I could solve it today.
>> Anyway, I think that Ocaml should support infix as SML.
>
>Camlp4
>
>--
>Daniel de RAUGLAUDRE
>daniel.de_rauglaudre@inria.fr
>http://cristal.inria.fr/~ddr/
>-------------------
>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
>
-------------------
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 prev parent reply other threads:[~2002-05-28 18:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-28 15:42 dengping zhu
2002-05-28 15:54 ` Remi VANICAT
2002-05-28 16:00 ` John Prevost
2002-05-28 17:19 ` dengping zhu
2002-05-28 18:07 ` John Prevost
2002-05-28 18:16 ` dengping zhu
2002-05-28 18:32 ` Daniel de Rauglaudre
2002-05-28 18:48 ` dengping zhu [this message]
2002-05-28 22:44 ` Daniel de Rauglaudre
2002-05-29 2:48 ` dengping zhu
2002-05-29 8:42 ` Daniel de Rauglaudre
2002-06-21 17:54 ` dengping zhu
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.0205281440380.4380-100000@csa.bu.edu \
--to=zhudp@cs.bu.edu \
--cc=caml-list@inria.fr \
--cc=daniel.de_rauglaudre@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