Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4: rules with arguments?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joel Reymont <joelr1@g...>
Subject: camlp4: rules with arguments?
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