summaryrefslogtreecommitdiff
path: root/expr.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-07-30 21:57:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-07-30 21:57:02 -0400
commit94e76ae87e883291d13320738fe165c7a2a2415b (patch)
treeb90eff2ee3737ecdfea96dbee52ecd239fcb2578 /expr.h
parent5087a60deef7c618a07562511e9a1fbf2414776c (diff)
downloadfork-ledger-94e76ae87e883291d13320738fe165c7a2a2415b.tar.gz
fork-ledger-94e76ae87e883291d13320738fe165c7a2a2415b.tar.bz2
fork-ledger-94e76ae87e883291d13320738fe165c7a2a2415b.zip
two major changes
Complete changed the way format strings are handled. They are now compiled first, which is far more efficient than what was being done before. Also, there is now a global ledger::commodity_t::commodities map, which saves me from having to pass the current journal around to a zillion different functions, for the sole purpose of making sure that all commodity symbols that are parsed refer to the same commodity object.
Diffstat (limited to 'expr.h')
-rw-r--r--expr.h106
1 files changed, 53 insertions, 53 deletions
diff --git a/expr.h b/expr.h
index 355f34c9..f4961bfc 100644
--- a/expr.h
+++ b/expr.h
@@ -7,55 +7,55 @@
namespace ledger {
-enum kind_t {
- // Constants
- CONSTANT_A,
- CONSTANT_T,
-
- // Item details
- AMOUNT,
- COST,
- DATE,
- INDEX,
-
- // Item totals
- BALANCE,
- COST_BALANCE,
- TOTAL,
- COST_TOTAL,
-
- // Constraint details
- BEGIN_DATE,
- END_DATE,
-
- // Functions
- F_ARITH_MEAN,
- F_VALUE,
- F_NEG,
- F_ABS,
- F_REGEXP,
-
- // Binary operators
- O_ADD,
- O_SUB,
- O_MUL,
- O_DIV,
- O_EQ,
- O_LT,
- O_LTE,
- O_GT,
- O_GTE,
- O_NOT,
- O_AND,
- O_OR,
- O_QUES,
- O_COL,
-
- LAST
-};
-
struct node_t
{
+ enum kind_t {
+ // Constants
+ CONSTANT_A,
+ CONSTANT_T,
+
+ // Item details
+ AMOUNT,
+ COST,
+ DATE,
+ INDEX,
+
+ // Item totals
+ BALANCE,
+ COST_BALANCE,
+ TOTAL,
+ COST_TOTAL,
+
+ // Constraint details
+ BEGIN_DATE,
+ END_DATE,
+
+ // Functions
+ F_ARITH_MEAN,
+ F_VALUE,
+ F_NEG,
+ F_ABS,
+ F_REGEXP,
+
+ // Binary operators
+ O_ADD,
+ O_SUB,
+ O_MUL,
+ O_DIV,
+ O_EQ,
+ O_LT,
+ O_LTE,
+ O_GT,
+ O_GTE,
+ O_NOT,
+ O_AND,
+ O_OR,
+ O_QUES,
+ O_COL,
+
+ LAST
+ };
+
kind_t type;
node_t * left;
node_t * right;
@@ -78,18 +78,18 @@ struct node_t
const std::time_t end = -1) const;
};
-node_t * parse_expr(std::istream& in, ledger_t * ledger);
+node_t * parse_expr(std::istream& in);
-inline node_t * parse_expr(const char * p, ledger_t * ledger) {
+inline node_t * parse_expr(const char * p) {
std::istringstream stream(p);
- return parse_expr(stream, ledger);
+ return parse_expr(stream);
}
-inline node_t * parse_expr(const std::string& str, ledger_t * ledger) {
- return parse_expr(str.c_str(), ledger);
+inline node_t * parse_expr(const std::string& str) {
+ return parse_expr(str.c_str());
}
-inline node_t * find_node(node_t * node, kind_t type) {
+inline node_t * find_node(node_t * node, node_t::kind_t type) {
node_t * result = NULL;
if (node->type == type)
result = node;