[wg-camlp4] My no-use of camlp4 syntax extensions for Otags

Alain Frisch alain.frisch at lexifi.com
Thu Apr 11 15:19:19 BST 2013


On 02/22/2013 01:32 PM, Hendrik Tews wrote:
> I would therefore strongly suggest to provide complete
> documentation for the ast that preprocessors must process with
> the _beta_ release of the next version.

Do you have a suggestion for the form such a documentation should take? 
  I can imagine describing how each fragment of concrete syntax is 
represented in the abstract syntax, but this would not be really 
different from paraphrasing the code of the parser.

The new tool "ocamlast" gives you an easy way to see how a piece of 
concrete syntax is represented:

~/ocaml/extension_points $ tools/ocamlast -e "1 + 3"
{pexp_desc =
   Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident "+"}},
    [("", {pexp_desc = Pexp_constant (Const_int 1)});
     ("", {pexp_desc = Pexp_constant (Const_int 3)})])}

~/ocaml/extension_points $ tools/ocamlast -p "'0'..'3'"
{ppat_desc =
   Ppat_or ({ppat_desc = Ppat_constant (Const_char '0')},
    {ppat_desc =
      Ppat_or ({ppat_desc = Ppat_constant (Const_char '1')},
       {ppat_desc =
         Ppat_or ({ppat_desc = Ppat_constant (Const_char '2')},
          {ppat_desc = Ppat_constant (Const_char '3')})})})}

(locations and empty attribute lists are omitted by default)

It seems to me that such a tool is actually a good replacement for an 
explicit documentation of the Parsetree, both for the user and for the 
maintainers.  Do you agree?


-- Alain


More information about the wg-camlp4 mailing list