class_declaration:
[ LEFTA
[ c1 = SELF; "and"; c2 = SELF ->
<:class_expr< $c1$ and $c2$ >>
| `ANTIQUOT (""|"cdcl"|"anti"|"list" as n) s ->
<:class_expr< $anti:mk_anti ~c:"class_expr" n s$ >>
| `QUOTATION x -> Quotation.expand _loc x
Quotation.DynAst.class_expr_tag
| ci = class_info_for_class_expr; ce = class_fun_binding ->
<:class_expr< $ci$ = $ce$ >>
] ]
It seems they are variants but that's about as much as I understand.
What are the "cdcl", "anti" or "list", for example? Why are they
strings?
And why is `QUOTATION x expanded into Quotation.expand _loc x
Quotation.DynAst.class_expr_tag?
Thanks in advance, Joel
_______________________________________________
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
The main page about camlp4 extensible grammars/parsers is:
http://brion.inria.fr/gallium/index.php/Extensible_Parser
The syntax of grammars is given in:
http://brion.inria.fr/gallium/index.php/EXTEND
* LEFTA is left associative (its the default).
* SELF refers to the current rule (class_declaration here), in most common
cases SELF does what you want.
ANTIQUOT and QUOTATION are token types like STRING, INT... The backquote
syntax mark the begining of an OCaml pattern. So ANTIQUOT is a constructor
(the token type [1]). The lexical syntax of an antiquotation is "$name:...$"
or "$...$", it use in order to treat quotations [2] such as
<:class_expr< myclass = object method m = $e$ end >>
where `e' should better be an expression (Ast.expr).
[1]: http://brion.inria.fr/gallium/index.php/Generic_Token_Type
[2]: http://brion.inria.fr/gallium/index.php/Quotation
>
> class_declaration:
> [ LEFTA
> [ c1 = SELF; "and"; c2 = SELF ->
> <:class_expr< $c1$ and $c2$ >>
> | `ANTIQUOT (""|"cdcl"|"anti"|"list" as n) s ->
> <:class_expr< $anti:mk_anti ~c:"class_expr" n s$ >>
> | `QUOTATION x -> Quotation.expand _loc x
> Quotation.DynAst.class_expr_tag
> | ci = class_info_for_class_expr; ce = class_fun_binding ->
> <:class_expr< $ci$ = $ce$ >>
> ] ]
>
> It seems they are variants but that's about as much as I understand.
> What are the "cdcl", "anti" or "list", for example? Why are they
> strings?
They are antiquotations names so you can write (don't pay attention to
"anti") <:class_expr< $cdcl:x$ and $list:xs$ >>.
> And why is `QUOTATION x expanded into Quotation.expand _loc x
> Quotation.DynAst.class_expr_tag?
When you see <:class_expr<...>> you give "..." to the quotation expander
manager that will call the registered expanding function (the class_expr_tag
is too indicate the requested type).
Best regards,
--
Nicolas Pouillard aka Ertai