From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "Joel Reymont" <joelr1@gmail.com>
Cc: "OCaml List" <caml-list@inria.fr>
Subject: Re: GenerateFold
Date: Thu, 31 May 2007 17:29:14 +0200 [thread overview]
Message-ID: <cd67f63a0705310829k17e9a4eej3cc15fcd66f08b15@mail.gmail.com> (raw)
In-Reply-To: <5F8F1647-A4A8-4C71-9958-9370C44ECB84@gmail.com>
On 5/31/07, Joel Reymont <joelr1@gmail.com> wrote:
> What is the proper use of GenerateFold here?
>
> What I'm trying to do is dig into my AST tree, starting with a list
> of statements at the top, to find out if I have any `FunArgDecl bits.
>
> At the top of the AST I have
>
> statement =
> [
> | `InputDecls of input_decl list
> ]
>
> and then
>
> input_decl =
> [
> | `InputDecl of id * ty * expr
> | `FunArgDecl of id * ty * subscript
> ]
>
> I tried the following approach but it's obviously wrong.
>
> class fold = Camlp4Filters.GenerateFold.generated;;
>
> let is_fun_arg = object
> inherit fold as super
> method input_decl x =
> match super#input_decl x with
> | `FunArgDecl _ -> true
> | _ -> false
> end
>
> let is_fun x = is_fun_arg#statement x;;
>
You must use the object itself that is threaded through the traversal
(or use an exception in that simple case).
Something like (not tested).
class fold = Camlp4Filters.GenerateFold.generated;;
let is_fun_arg = object
inherit fold as super
val found = false
method found = found
method input_decl x =
match super#input_decl x with
| `FunArgDecl _ -> {< found = true >}
| _ -> self
end
let is_fun x = (is_fun_arg#statement x)#found;;
--
Nicolas Pouillard
next prev parent reply other threads:[~2007-05-31 15:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-31 12:18 GenerateFold Joel Reymont
2007-05-31 15:29 ` Nicolas Pouillard [this message]
2007-05-31 17:41 ` GenerateFold Joel Reymont
2007-05-31 18:58 ` GenerateFold Joel Reymont
2007-05-31 22:05 ` GenerateFold Nicolas Pouillard
2007-05-31 22:16 ` GenerateFold Joel Reymont
2007-05-31 22:34 ` GenerateFold Joel Reymont
2007-06-01 6:08 ` [Caml-list] GenerateFold Edgar Friendly
2007-06-01 13:22 ` Joel Reymont
2007-06-01 13:30 ` Nicolas Pouillard
2007-06-01 13:44 ` Joel Reymont
2007-06-01 16:07 ` Nicolas Pouillard
2007-06-05 12:25 ` Nicolas Pouillard
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=cd67f63a0705310829k17e9a4eej3cc15fcd66f08b15@mail.gmail.com \
--to=nicolas.pouillard@gmail.com \
--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