From: "Nicolas Pouillard" <nicolas.pouillard@inria.fr>
To: joelr1 <joelr1@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] camlp4: Understanding class_declaration
Date: Sat, 06 Oct 2007 09:35:06 +0200 [thread overview]
Message-ID: <1191655159-sup-9578@ausone.local> (raw)
In-Reply-To: <ACF73769-6006-45B8-AC9F-72032BE76B2D@gmail.com>
Excerpts from joelr1's message of Thu Oct 04 18:40:58 +0200 2007:
> Would someone kindly explain LEFTA, SELF, ANTIQUOT and QUOTATION below?
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
prev parent reply other threads:[~2007-10-06 7:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-04 16:40 Joel Reymont
2007-10-06 7:35 ` Nicolas Pouillard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1191655159-sup-9578@ausone.local \
--to=nicolas.pouillard@inria.fr \
--cc=caml-list@inria.fr \
--cc=joelr1@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox