caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* camlp4: str_item quotations for normal syntax
@ 2008-03-31 11:27 Hendrik Tews
  2008-04-01  8:23 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 2+ messages in thread
From: Hendrik Tews @ 2008-03-31 11:27 UTC (permalink / raw)
  To: caml-list

Hi,

I am trying to use (anti-) quotations for the normal ocaml syntax
and run into the following problems:

1. when pattern matching over str_item, what's the antiquotation
   to use to get the list of all str_item's in a structure or in
   a compilation unit?

   One can use Ast.list_of_str_item, for instance

    | <:str_item@loc< module $uid:mname$ = struct $items$ end >> -> 
           .... (Ast.list_of_str_item items)

   but what's the antiquotation for directly getting the list?

   I found str_items in Camlp4OCamlRevisedParser, and tried

    (match ast with
       | <:str_items< $list:tops$ >> ->
    	 Printf.printf "%s has %d top level decls\n"
    	   (opt_string input_file) (List.length tops));

   but there is no quotation expander for str_items. 

   Further, str_items appears in module_expr but not in implem or
   top_phrase. Why not?

2. Ast.list_of_str_item is defined but never used, right? I am
   guessing that there is a line missing in
   Camlp4QuotationCommon.ml, similar to the one with
   Ast.stSem_of_list. Right?

3. The str_item quotations for the ocaml syntax seem to produce
   always Ast.StSem(...,..., Ast.StNil...), for instance

    | <:str_item@loc< type $lid:name$ = $lid:oname$ >> ->

   gives

      | Ast.StSem (loc,
          (Ast.StTyp (_,
             (Ast.TyDcl (_, name, [], (Ast.TyId (_, (Ast.IdLid (_, oname)))),
                [])))),
          (Ast.StNil _)) ->

   What do I have to write in order to get just 

      | Ast.StTyp (loc,
          (Ast.TyDcl (_, name, [], (Ast.TyId (_, (Ast.IdLid (_, oname)))),
             [])))
          ->

   as I get with the revised qotations?


4. What is the quotation for _just_ getting Ast.StSem(_,_,_) for
   instance for doing

   List.iter (function
               | Ast.StSem(_,_,_) -> assert false
               | .....
      ) (Ast.list_of_str_item ....)


5. What is Register.OCamlPreCastPrinter good for?

6. I would be interested in contributing for a version of
   http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree
   for ocaml syntax. 

   Nicolas, Matthieu: What would you prefer as best structure? A
   separate page with lots of duplication or one page for ocaml
   and revised syntax, possibly differentiating things with
   color? I tend to the latter.


Bye,

Hendrik


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-01  8:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-31 11:27 camlp4: str_item quotations for normal syntax Hendrik Tews
2008-04-01  8:23 ` [Caml-list] " Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).