caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] passing argument in campl4 ?
Date: 30 Mar 2005 11:37:41 +0200	[thread overview]
Message-ID: <rl1x9xjwyi.fsf@ithif59.inf.tu-dresden.de> (raw)
In-Reply-To: <20050324052918.GA30200@pulp.anu.edu.au>

Pietro Abate <Pietro.Abate@anu.edu.au> writes:

   aa: [[ "AA"; c = bb "val" -> "aa"^c ]];
   to 
   bb arg: [[ a = INT; "BB" -> a ]];
   
The camlp4 reference manual
(http://caml.inria.fr/pub/docs/manual-camlp4/manual005.html) says
the syntax of a rule is 

   { pattern = } symbol ; ... { pattern = } symbol { -> action }

so you can't pass an argument to bb.

I can think two possible solutions:

1. Extend the camlp4 syntax for grammar extentions with a new
   metasymbol "bb" that takes one argument, similar to the
   metasymbols LIST0 and LIST1

2. Use something like

  aa: [[ x = do_the_aa_rule -> ... ]]

with 

let do_the_aa_rule = Grammar.Entry.of_parser gram "do_the_aa_rule" 
                        (* a (Token.t Stream.t -> 'a) function,
                           where 'a is the type of x above *)

The ocaml parser distributed with camlp4 contains examples for
the latter technique, see for instance infixop0 or test_label_eq
in camlp4/etc/pa_o.ml. Further, these sources seem to indicate
that there is no nice solution to your problem: The levels "||"
to "**" of the entry expr could benefit from some more
abstraction.

Bye,

Hendrik


      reply	other threads:[~2005-03-30  9:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-24  5:29 Pietro Abate
2005-03-30  9:37 ` Hendrik Tews [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=rl1x9xjwyi.fsf@ithif59.inf.tu-dresden.de \
    --to=tews@tcs.inf.tu-dresden.de \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).