diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-03 13:26:27 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-03 13:26:27 -0400 |
commit | 0f9d919367ada929daa6fc8d8a176a4ba63308b2 (patch) | |
tree | 71f2674b7785d0754572600791c7ca5d8c2869ed /src/token.cc | |
parent | d7b9f9e068d6817944854a31df1fc34258707a1a (diff) | |
download | fork-ledger-0f9d919367ada929daa6fc8d8a176a4ba63308b2.tar.gz fork-ledger-0f9d919367ada929daa6fc8d8a176a4ba63308b2.tar.bz2 fork-ledger-0f9d919367ada929daa6fc8d8a176a4ba63308b2.zip |
Added Python-style if/else expression keywords
Diffstat (limited to 'src/token.cc')
-rw-r--r-- | src/token.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/token.cc b/src/token.cc index 6935bc7a..0a8fce7e 100644 --- a/src/token.cc +++ b/src/token.cc @@ -38,7 +38,8 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) { char c = static_cast<char>(in.peek()); - if (c == 'a' || c == 'd' || c == 'f' || c == 'o' || c == 'n' || c == 't') { + if (c == 'a' || c == 'd' || c == 'e' || c == 'f' || + c == 'i' || c == 'o' || c == 'n' || c == 't') { length = 0; char buf[6]; @@ -64,6 +65,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) } break; + case 'e': + if (std::strcmp(buf, "else") == 0) { + symbol[0] = 'L'; + symbol[1] = 'S'; + symbol[2] = '\0'; + kind = KW_ELSE; + return 1; + } + break; + case 'f': if (std::strcmp(buf, "false") == 0) { kind = VALUE; @@ -72,6 +83,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) } break; + case 'i': + if (std::strcmp(buf, "if") == 0) { + symbol[0] = 'i'; + symbol[1] = 'f'; + symbol[2] = '\0'; + kind = KW_IF; + return 1; + } + break; + case 'o': if (std::strcmp(buf, "or") == 0) { symbol[0] = '|'; |