caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jeff Henrikson" <jehenrik@yahoo.com>
To: <caml-list@inria.fr>
Subject: [Caml-list] camlp4: generating keyword on the fly
Date: Sat, 12 Jan 2002 20:28:49 -0500	[thread overview]
Message-ID: <005201c19bd1$a72e8b00$0b01a8c0@mit.edu> (raw)

I want to be able to cook up keywords on the fly using camlp4, and it seems like I should be able to do it.  But this is as far as
I get.  This function compiles:


let make_one_item_entry entrysym (keyword : string) =
  let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
  EXTEND
    tmp: [ [ "birthday" ] ]
    ;
  END;
  tmp;;

Grammar.Entry.print (make_one_item_entry "happy" "birthday");;

# [ LEFTA
  [ "birthday" ] ]
- : unit = ()


But this one does not:


let make_one_item_entry entrysym (keyword : string) =
  let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
  EXTEND
    tmp: [ [ keyword ] ]
    ;
  END;
  tmp;;

Grammar.Entry.print (make_one_item_entry "happy" "birthday");;


Note that this looks right but isn't:


let make_one_item_entry entrysym (keyword : string) =
  let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
  let tmp2 = (Grammar.Entry.create Pcaml.gram keyword) in
  EXTEND
    tmp: [ [ tmp2 ] ]
    ;
  END;
  tmp;;

Grammar.Entry.print (make_one_item_entry "happy" "birthday");;

# [ LEFTA
  [ birthday ] ]
- : unit = ()


(The quotes are missing)  I'm new at camlp4, so I don't know if my jargon for explaining this is right, but:

I can get an empty entry with Grammar.Entry.create, but the only way to extend it seems to be with EXTEND which so far as I can see
only takes string constants.  Does this make sense?


Jeff Henrikson


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2002-01-13  1:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-13  1:28 Jeff Henrikson [this message]
2002-01-13  1:41 ` Daniel de Rauglaudre

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='005201c19bd1$a72e8b00$0b01a8c0@mit.edu' \
    --to=jehenrik@yahoo.com \
    --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).