From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: ocaml ml <caml-list@inria.fr>
Subject: passing argument in campl4 ?
Date: Thu, 24 Mar 2005 16:29:18 +1100 [thread overview]
Message-ID: <20050324052918.GA30200@pulp.anu.edu.au> (raw)
Hi all,
I've this small example below that I'd like to modify to
pass information top-down, from aa to bb (this is definitely
possible using parser and streams).
I see bb as a function but as it is translated (below below)
is not entirely clear to me how I can pass a value from
aa: [[ "AA"; c = bb "val" -> "aa"^c ]];
to
bb arg: [[ a = INT; "BB" -> a ]];
I don't think this is directly possible (using the pseudo
syntax above), but I was wonder if you have a trick to
achieve something similar...
p
---------------- -------------------
(*pp camlp4o -I . pa_extend.cmo q_MLast.cmo *)
open Pcaml
let aa = Grammar.Entry.create gram "aa"
let bb = Grammar.Entry.create gram "bb"
EXTEND
aa: [[ "AA"; c = bb -> "aa"^c ]];
bb: [[ a = INT; "BB" -> a ]];
END
------------------dump ------------------------
(*pp camlp4o -I . pa_extend.cmo q_MLast.cmo *)
open Pcaml
let aa = Grammar.Entry.create gram "aa"
let bb = Grammar.Entry.create gram "bb"
let _ =
Grammar.extend
[Grammar.Entry.obj (aa : 'aa Grammar.Entry.e), None,
[None, None,
[[Gramext.Stoken ("", "AA");
Gramext.Snterm (Grammar.Entry.obj (bb : 'bb Grammar.Entry.e))],
Gramext.action
(fun (c : 'bb) _ (loc : Lexing.position * Lexing.position) ->
("aa" ^ c : 'aa))]];
Grammar.Entry.obj (bb : 'bb Grammar.Entry.e), None,
[None, None,
[[Gramext.Stoken ("INT", ""); Gramext.Stoken ("", "BB")],
Gramext.action
(fun _ (a : string) (loc : Lexing.position * Lexing.position) ->
(a : 'bb))]]]
--
++ WebBlog/Diary: http://blog.rsise.anu.edu.au/?q=pietro
++
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
next reply other threads:[~2005-03-24 5:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-24 5:29 Pietro Abate [this message]
2005-03-30 9:37 ` [Caml-list] " Hendrik Tews
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=20050324052918.GA30200@pulp.anu.edu.au \
--to=pietro.abate@anu.edu.au \
--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