* camlp4: rules with arguments?
@ 2009-03-13 18:40 Joel Reymont
0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2009-03-13 18:40 UTC (permalink / raw)
To: O'Caml Mailing List
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-13 18:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-13 18:40 camlp4: rules with arguments? Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox