diff options
author | John Wiegley <johnw@newartisans.com> | 2010-09-05 01:38:47 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-09-05 01:38:47 -0400 |
commit | e162455ebb545ea33580e58f52ebe424ef9e68fa (patch) | |
tree | df9c98fb39f31b9003db07d7806815bf71031a2d /src/token.cc | |
parent | 9fcf48482626f20151d75a2ebb81371b45d4540a (diff) | |
download | fork-ledger-e162455ebb545ea33580e58f52ebe424ef9e68fa.tar.gz fork-ledger-e162455ebb545ea33580e58f52ebe424ef9e68fa.tar.bz2 fork-ledger-e162455ebb545ea33580e58f52ebe424ef9e68fa.zip |
Minor simplifications to valexpr parser
The most significant change is the way CONS sequences are parsed, and
that now instead of =/:=, the operators are ==/=.
Diffstat (limited to 'src/token.cc')
-rw-r--r-- | src/token.cc | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/token.cc b/src/token.cc index 67cff65e..be39205c 100644 --- a/src/token.cc +++ b/src/token.cc @@ -60,8 +60,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) case 'd': if (std::strcmp(buf, "div") == 0) { symbol[0] = '/'; - symbol[1] = '/'; - symbol[2] = '\0'; + symbol[1] = '\0'; kind = KW_DIV; return 1; } @@ -69,9 +68,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) case 'e': if (std::strcmp(buf, "else") == 0) { - symbol[0] = 'L'; - symbol[1] = 'S'; - symbol[2] = '\0'; + std::strcpy(symbol, "else"); kind = KW_ELSE; return 1; } @@ -79,6 +76,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) case 'f': if (std::strcmp(buf, "false") == 0) { + std::strcpy(symbol, "false"); kind = VALUE; value = false; return 1; @@ -115,6 +113,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) case 't': if (std::strcmp(buf, "true") == 0) { + std::strcpy(symbol, "true"); kind = VALUE; value = true; return 1; @@ -231,6 +230,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags, break; } +#if 0 case '{': { in.get(c); amount_t temp; @@ -243,6 +243,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags, value = temp; break; } +#endif case '!': in.get(c); @@ -287,14 +288,6 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags, case ':': in.get(c); c = static_cast<char>(in.peek()); - if (c == '=') { - in.get(c); - symbol[1] = c; - symbol[2] = '\0'; - kind = DEFINE; - length = 2; - break; - } kind = COLON; break; @@ -336,7 +329,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags, length = 2; break; } - kind = EQUAL; + kind = DEFINE; break; case '<': @@ -403,6 +396,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags, // maximum displayed precision. parse_flags_t parse_flags; + parse_flags.add_flags(PARSE_NO_ANNOT); if (pflags.has_flags(PARSE_NO_MIGRATE)) parse_flags.add_flags(PARSE_NO_MIGRATE); if (pflags.has_flags(PARSE_NO_REDUCE)) |