caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: camlp4: rules with arguments?
Date: Fri, 13 Mar 2009 18:40:02 +0000	[thread overview]
Message-ID: <1355E60A-9665-40A1-A2F4-16930F7CDC92@gmail.com> (raw)

I have two rules designed to parse these statements

buy 100 shares next bar at market
buy 100 shares # assumes next bar at market
sell 100 shares next bar 20 stop
...

The rules are the same, except "Higher" and "Lower" get swapped when  
combined with "Stop" and "Limit".

Since either buyMethod or sellMethod is optional, the rules are used  
as "OPT buyMethod" and "OPT sellMethod".

Is there a way to parameterize these rules or should I keep them as is?

Can the rules be simplified?

	Thanks, Joel

---

   buyMethod:
   [
     [ "Next"; "Bar";
       x = [ x = [ at = OPT "At$"; e = expr; [ "Stop" | "Higher" ] ->  
(Stop e, at)
           | at = OPT "At$"; e = expr; [ "Limit" | "Lower" ] -> (Limit  
e, at)
           | "Market" -> (Market, None)
           ] -> x
       | -> (Market, None)
       ] -> x
     ]
   ];

   sellMethod:
   [
     [ "Next"; "Bar";
       x = [ x = [ at = OPT "At$"; e = expr; [ "Stop" | "Lower" ] ->  
(Stop e, at)
           | at = OPT "At$"; e = expr; [ "Limit" | "Higher" ] ->  
(Limit e, at)
           | "Market" -> (Market, None)
           ] -> x
       | -> (Market, None)
       ] -> x
     ]
   ];

---
http://tinyco.de
Mac, C++, OCaml


                 reply	other threads:[~2009-03-13 18:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1355E60A-9665-40A1-A2F4-16930F7CDC92@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@yquem.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).