summaryrefslogtreecommitdiff
path: root/src/token.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-11 16:03:50 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-11 17:02:25 -0400
commitdea2aed0b509734ec4e1cd163ac2a4f013000da2 (patch)
tree7908da76c67ae5172882306a319bf26df81b73b4 /src/token.cc
parentd580079df892c30d023b3211d6c4611c17b11f8f (diff)
downloadfork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.gz
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.bz2
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.zip
Untabified all source files
Diffstat (limited to 'src/token.cc')
-rw-r--r--src/token.cc132
1 files changed, 66 insertions, 66 deletions
diff --git a/src/token.cc b/src/token.cc
index 905e13fe..9dfff065 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -50,74 +50,74 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
switch (buf[0]) {
case 'a':
if (std::strcmp(buf, "and") == 0) {
- symbol[0] = '&';
- symbol[1] = '\0';
- kind = KW_AND;
- return 1;
+ symbol[0] = '&';
+ symbol[1] = '\0';
+ kind = KW_AND;
+ return 1;
}
break;
case 'd':
if (std::strcmp(buf, "div") == 0) {
- symbol[0] = '/';
- symbol[1] = '/';
- symbol[2] = '\0';
- kind = KW_DIV;
- return 1;
+ symbol[0] = '/';
+ symbol[1] = '/';
+ symbol[2] = '\0';
+ kind = KW_DIV;
+ return 1;
}
break;
case 'e':
if (std::strcmp(buf, "else") == 0) {
- symbol[0] = 'L';
- symbol[1] = 'S';
- symbol[2] = '\0';
- kind = KW_ELSE;
- return 1;
+ 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;
- value = false;
- return 1;
+ kind = VALUE;
+ value = false;
+ return 1;
}
break;
case 'i':
if (std::strcmp(buf, "if") == 0) {
- symbol[0] = 'i';
- symbol[1] = 'f';
- symbol[2] = '\0';
- kind = KW_IF;
- return 1;
+ 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] = '|';
- symbol[1] = '\0';
- kind = KW_OR;
- return 1;
+ symbol[0] = '|';
+ symbol[1] = '\0';
+ kind = KW_OR;
+ return 1;
}
break;
case 'n':
if (std::strcmp(buf, "not") == 0) {
- symbol[0] = '!';
- symbol[1] = '\0';
- kind = EXCLAM;
- return 1;
+ symbol[0] = '!';
+ symbol[1] = '\0';
+ kind = EXCLAM;
+ return 1;
}
break;
case 't':
if (std::strcmp(buf, "true") == 0) {
- kind = VALUE;
- value = true;
- return 1;
+ kind = VALUE;
+ value = true;
+ return 1;
}
break;
}
@@ -129,7 +129,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
void expr_t::token_t::parse_ident(std::istream& in)
{
- kind = IDENT;
+ kind = IDENT;
length = 0;
char c, buf[256];
@@ -139,7 +139,7 @@ void expr_t::token_t::parse_ident(std::istream& in)
}
void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
- const char expecting)
+ const char expecting)
{
if (in.eof()) {
kind = TOK_EOF;
@@ -210,7 +210,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
optional<date_t> begin = timespan.begin();
if (! begin)
throw_(parse_error,
- _("Date specifier does not refer to a starting date"));
+ _("Date specifier does not refer to a starting date"));
kind = VALUE;
value = *begin;
break;
@@ -302,12 +302,12 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
in.get(c);
if (pflags.has_flags(PARSE_OP_CONTEXT)) { // operator context
kind = SLASH;
- } else { // terminal context
+ } else { // terminal context
// Read in the regexp
char buf[256];
READ_INTO_(in, buf, 255, c, length, c != '/');
if (c != '/')
- expected('/', c);
+ expected('/', c);
in.get(c);
length++;
@@ -395,7 +395,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
in.clear();
in.seekg(pos, std::ios::beg);
if (in.fail())
- throw_(parse_error, _("Failed to reset input stream"));
+ throw_(parse_error, _("Failed to reset input stream"));
}
// When in relaxed parsing mode, we want to migrate commodity flags
@@ -411,30 +411,30 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
try {
amount_t temp;
if (! temp.parse(in, parse_flags.plus_flags(PARSE_SOFT_FAIL))) {
- // If the amount had no commodity, it must be an unambiguous
- // variable reference
-
- in.clear();
- in.seekg(pos, std::ios::beg);
- if (in.fail())
- throw_(parse_error, _("Failed to reset input stream"));
-
- c = static_cast<char>(in.peek());
- if (std::isdigit(c) || c == '.')
- expected('\0', c);
-
- parse_ident(in);
-
- if (value.as_string().length() == 0) {
- kind = ERROR;
- symbol[0] = c;
- symbol[1] = '\0';
- unexpected(expecting);
- }
+ // If the amount had no commodity, it must be an unambiguous
+ // variable reference
+
+ in.clear();
+ in.seekg(pos, std::ios::beg);
+ if (in.fail())
+ throw_(parse_error, _("Failed to reset input stream"));
+
+ c = static_cast<char>(in.peek());
+ if (std::isdigit(c) || c == '.')
+ expected('\0', c);
+
+ parse_ident(in);
+
+ if (value.as_string().length() == 0) {
+ kind = ERROR;
+ symbol[0] = c;
+ symbol[1] = '\0';
+ unexpected(expecting);
+ }
} else {
- kind = VALUE;
- value = temp;
- length = static_cast<std::size_t>(in.tellg() - pos);
+ kind = VALUE;
+ value = temp;
+ length = static_cast<std::size_t>(in.tellg() - pos);
}
}
catch (const std::exception& err) {
@@ -476,16 +476,16 @@ void expr_t::token_t::unexpected(const char wanted)
switch (prev_kind) {
case TOK_EOF:
throw_(parse_error,
- _("Unexpected end of expression (wanted '%1')") << wanted);
+ _("Unexpected end of expression (wanted '%1')") << wanted);
case IDENT:
throw_(parse_error,
- _("Unexpected symbol '%1' (wanted '%2')") << value << wanted);
+ _("Unexpected symbol '%1' (wanted '%2')") << value << wanted);
case VALUE:
throw_(parse_error,
- _("Unexpected value '%1' (wanted '%2')") << value << wanted);
+ _("Unexpected value '%1' (wanted '%2')") << value << wanted);
default:
throw_(parse_error, _("Unexpected expression token '%1' (wanted '%2')")
- << symbol << wanted);
+ << symbol << wanted);
}
}
}