diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-31 01:21:14 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-31 01:21:14 -0400 |
commit | c5795c66c9044c347332812498b888787e0edd4a (patch) | |
tree | 02c06509902ba8b38b7d8688d5e67ba47d177b6f /src/token.cc | |
parent | 75f1cd727cc4de5640a529f331da5c1b9a6ce00b (diff) | |
download | fork-ledger-c5795c66c9044c347332812498b888787e0edd4a.tar.gz fork-ledger-c5795c66c9044c347332812498b888787e0edd4a.tar.bz2 fork-ledger-c5795c66c9044c347332812498b888787e0edd4a.zip |
"div", or "//", is now the operator of division.
Diffstat (limited to 'src/token.cc')
-rw-r--r-- | src/token.cc | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/token.cc b/src/token.cc index f2b43ffb..a16bdc46 100644 --- a/src/token.cc +++ b/src/token.cc @@ -38,12 +38,11 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) { char c = in.peek(); - if (c == 'a' || c == 'f' || c == 'o' || c == 'n' || c == 't') { + if (c == 'a' || c == 'd' || c == 'f' || c == 'o' || c == 'n' || c == 't') { length = 0; - char buf[256]; - READ_INTO_(in, buf, 255, c, length, - std::isalnum(c) || c == '_' || c == '.' || c == '-'); + char buf[5]; + READ_INTO_(in, buf, 4, c, length, std::isalpha(c)); switch (buf[0]) { case 'a': @@ -55,6 +54,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) } break; + case 'd': + if (std::strcmp(buf, "div") == 0) { + symbol[0] = '/'; + symbol[1] = '/'; + symbol[2] = '\0'; + kind = KW_DIV; + return 1; + } + break; + case 'f': if (std::strcmp(buf, "false") == 0) { kind = VALUE; @@ -255,17 +264,25 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags) case '/': { in.get(c); + c = in.peek(); + if (c == '/') { + in.get(c); + symbol[1] = c; + symbol[2] = '\0'; + kind = KW_DIV; + length = 2; + } else { + // Read in the regexp + char buf[256]; + READ_INTO_(in, buf, 255, c, length, c != '/'); + if (c != '/') + expected('/', c); + in.get(c); + length++; - // Read in the regexp - char buf[256]; - READ_INTO_(in, buf, 255, c, length, c != '/'); - if (c != '/') - expected('/', c); - in.get(c); - length++; - - kind = MASK; - value.set_string(buf); + kind = MASK; + value.set_string(buf); + } break; } |