Version française
Home     About     Download     Resources     Contact us    
Browse thread
combining camlp4 extensions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: Re: [Caml-list] combining camlp4 extensions
There's something magic about this list... as soon as I post something I
come up with a solution... must be the ocaml-guru karma reaching my
office... anyway...

This example now works as expected... 

Is this the best way of solving this problem ?

------------ ext_repeat.ml
open Pcaml
open Repeat (* <--------- I need to refer to the grammar entity declared
               in the common part to be able to extend it !!!!!! *)

let extend () =
    EXTEND
    GLOBAL: reexpr;
      reexpr: [[ e = expr -> e ]];
    END
;;
-----------

-----------repeat.ml
open Pcaml
let reexpr = Grammar.Entry.create Pcaml.gram "reexpr";;
let extend () =
    EXTEND
    GLOBAL: reexpr expr ;
      expr: LEVEL "expr1"
        [[ "repeat"; e1 = reexpr; "until"; e2 = expr ->
              <:expr< do { $e1$; while not $e2$ do { $e1$; } } >> ]];

      reexpr: [[]];
    END
;;
--------------

-- 
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html