English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
How to achieve this camlp4 syntax extension
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-02 (11:42)
From: Conglun Yao <yaoconglun@g...>
Subject: How to achieve this camlp4 syntax extension
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)


GLOBAL: expr;

expr: LEVEL "top"[
[ e1 = module_longident; ".";  "[";  (*t = test_syntax;*)  "]" ->
  <:expr< $id:e1$ test >>


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.