diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-10 01:05:12 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-10 01:05:12 -0500 |
commit | 09c9ec4b41fa93c2a4637b5715bbb8dedf875192 (patch) | |
tree | 944c29ab7c9d641ce2624130406f01d84765a490 | |
parent | c927c74c2d6fb0aabb95e552af8ca5ec1e749cd1 (diff) | |
download | fork-ledger-09c9ec4b41fa93c2a4637b5715bbb8dedf875192.tar.gz fork-ledger-09c9ec4b41fa93c2a4637b5715bbb8dedf875192.tar.bz2 fork-ledger-09c9ec4b41fa93c2a4637b5715bbb8dedf875192.zip |
Directives no longer require @ or ! prefix char
-rw-r--r-- | src/textual.cc | 121 |
1 files changed, 62 insertions, 59 deletions
diff --git a/src/textual.cc b/src/textual.cc index badbdee5..238098f1 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -125,7 +125,7 @@ namespace { void tag_directive(char * line); void pop_directive(char * line); void define_directive(char * line); - void general_directive(char * line); + bool general_directive(char * line); post_t * parse_post(char * line, std::streamsize len, @@ -354,51 +354,53 @@ void instance_t::read_next_directive() period_xact_directive(line); break; -#if defined(TIMELOG_SUPPORT) - case 'i': - clock_in_directive(line, false); - break; - case 'I': - clock_in_directive(line, true); - break; - - case 'o': - clock_out_directive(line, false); - break; - case 'O': - clock_out_directive(line, true); - break; - - case 'h': - case 'b': - break; -#endif // TIMELOG_SUPPORT - - case 'A': // a default account for unbalanced posts - default_account_directive(line); - break; - case 'C': // a set of conversions - price_conversion_directive(line); - break; - case 'D': // a default commodity for "xact" - default_commodity_directive(line); - break; - case 'N': // don't download prices - nomarket_directive(line); - break; - case 'P': // a pricing xact - price_xact_directive(line); - break; - case 'Y': // set the current year - year_directive(line); - break; - case '@': case '!': line++; // fall through... default: // some other directive - general_directive(line); + if (! general_directive(line)) { + switch (line[0]) { +#if defined(TIMELOG_SUPPORT) + case 'i': + clock_in_directive(line, false); + break; + case 'I': + clock_in_directive(line, true); + break; + + case 'o': + clock_out_directive(line, false); + break; + case 'O': + clock_out_directive(line, true); + break; + + case 'h': + case 'b': + break; +#endif // TIMELOG_SUPPORT + + case 'A': // a default account for unbalanced posts + default_account_directive(line); + break; + case 'C': // a set of conversions + price_conversion_directive(line); + break; + case 'D': // a default commodity for "xact" + default_commodity_directive(line); + break; + case 'N': // don't download prices + nomarket_directive(line); + break; + case 'P': // a pricing xact + price_xact_directive(line); + break; + case 'Y': // set the current year + year_directive(line); + break; + } + } break; } } @@ -689,58 +691,56 @@ void instance_t::define_directive(char * line) def.compile(scope); // causes definitions to be established } -void instance_t::general_directive(char * line) +bool instance_t::general_directive(char * line) { - char * p = line; - char * arg = next_element(line); - + char * p = line; if (*p == '@' || *p == '!') p++; switch (*p) { case 'a': if (std::strcmp(p, "account") == 0) { - account_directive(arg); - return; + account_directive(next_element(line)); + return true; } else if (std::strcmp(p, "alias") == 0) { - alias_directive(arg); - return; + alias_directive(next_element(line)); + return true; } break; case 'd': if (std::strcmp(p, "def") == 0) { - define_directive(arg); - return; + define_directive(next_element(line)); + return true; } break; case 'e': if (std::strcmp(p, "end") == 0) { - end_directive(arg); - return; + end_directive(next_element(line)); + return true; } break; case 'i': if (std::strcmp(p, "include") == 0) { - include_directive(arg); - return; + include_directive(next_element(line)); + return true; } break; case 'p': if (std::strcmp(p, "pop") == 0) { - pop_directive(arg); - return; + pop_directive(next_element(line)); + return true; } break; case 't': if (std::strcmp(p, "tag") == 0) { - tag_directive(arg); - return; + tag_directive(next_element(line)); + return true; } break; } @@ -749,7 +749,10 @@ void instance_t::general_directive(char * line) call_scope_t args(*this); args.push_back(string_value(p)); op->as_function()(args); + return true; } + + return false; } post_t * instance_t::parse_post(char * line, |