diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-22 18:53:59 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-22 18:53:59 -0400 |
commit | 9c164bd3dc3a3eb97d827a1383a845dcd49933c7 (patch) | |
tree | 3c740238bbbc1d8f1a817ce4c63d7ac8588fd4cb /src/parser.cc | |
parent | e95e8c3f792c8801f5e0c31a3a2234a0ccc553e9 (diff) | |
download | fork-ledger-9c164bd3dc3a3eb97d827a1383a845dcd49933c7.tar.gz fork-ledger-9c164bd3dc3a3eb97d827a1383a845dcd49933c7.tar.bz2 fork-ledger-9c164bd3dc3a3eb97d827a1383a845dcd49933c7.zip |
Allow function calls without arguments in the parser.
Diffstat (limited to 'src/parser.cc')
-rw-r--r-- | src/parser.cc | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/parser.cc b/src/parser.cc index f47a76db..82bc771d 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -55,13 +55,12 @@ expr_t::parser_t::parse_value_term(std::istream& in, case token_t::IDENT: { string ident = tok.value.as_string(); + node = new op_t(op_t::IDENT); + node->set_ident(ident); + // An identifier followed by ( represents a function call tok = next_token(in, tflags); - if (tok.kind == token_t::LPAREN) { - node = new op_t(op_t::IDENT); - node->set_ident(ident); - ptr_op_t call_node(new op_t(op_t::O_CALL)); call_node->set_left(node); node = call_node; @@ -69,13 +68,6 @@ expr_t::parser_t::parse_value_term(std::istream& in, push_token(tok); // let the parser see it again node->set_right(parse_value_expr(in, tflags | EXPR_PARSE_SINGLE)); } else { - if (std::isdigit(ident[0])) { - node = new op_t(op_t::INDEX); - node->set_index(lexical_cast<unsigned int>(ident.c_str())); - } else { - node = new op_t(op_t::IDENT); - node->set_ident(ident); - } push_token(tok); } break; @@ -84,9 +76,6 @@ expr_t::parser_t::parse_value_term(std::istream& in, case token_t::LPAREN: node = parse_value_expr(in, (tflags | EXPR_PARSE_PARTIAL) & ~EXPR_PARSE_SINGLE); - if (! node) - throw_(parse_error, "Left parenthesis not followed by an expression"); - tok = next_token(in, tflags); if (tok.kind != token_t::RPAREN) tok.expected(')'); |