From 9c164bd3dc3a3eb97d827a1383a845dcd49933c7 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 22 Jan 2009 18:53:59 -0400 Subject: Allow function calls without arguments in the parser. --- src/parser.cc | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/parser.cc') 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(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(')'); -- cgit v1.2.3