Browse thread
How to achieve this camlp4 syntax extension
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-04-02 (12:39) |
From: | David Teller <David.Teller@u...> |
Subject: | Re: [Caml-list] How to achieve this camlp4 syntax extension |
Hi, I'm not going to quite answer your question yet -- I'd need to check the source of Camlp4 for this. However, I can point out that what you're trying to do looks very much like pa_open, by Alain Frisch. let _ = open M1.M2 in e will execute [e] using module [M1.M2]. Cheers, David On Thu, 2009-04-02 at 12:42 +0100, Conglun Yao wrote: > Dear all, > > I tried to achieve the following syntax extension, but failed. > > Add expression .[ ] after a module name, inside .[ ] I want to refer > to the specified module, like > > let _ = M1.M2.[ here is my syntax, using M1.M2 module ] > > Here is my attempt (failed) > > EXTEND Gram > > GLOBAL: expr; > > expr: LEVEL "top"[ > [ e1 = module_longident; "."; "["; (*t = test_syntax;*) "]" -> > <:expr< $id:e1$ test >> > ]]; > > END > > Different kinds of error happened, when trying to use it. > > Even the ordinary expression: List.length [1; 2;3 ], failed. 'List' > is parsed as module_longident, try to match the rule I defined. > > Thanks for any help. > > Conglun > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >