]> www.ginac.de Git - ginac.git/blobdiff - ginac/parser/parser.cpp
Parser can parse (some) floating point numbers now.
[ginac.git] / ginac / parser / parser.cpp
index f48d37fdf5c495916d7d3c0330d92068ecdde868..6411ba1416e740a85705ceee3153815b33e9364f 100644 (file)
@@ -121,6 +121,7 @@ ex parser::parse_number_expr()
 /// literal_expr: 'I' | 'Pi' | 'Euler' | 'Catalan'
 ex parser::parse_literal_expr()
 {
+       get_next_tok(); // consume the literal
        if (scanner->str == "I")
                return I;
        else if (scanner->str == "Pi")
@@ -137,6 +138,13 @@ ex parser::operator()(std::istream& input)
        scanner->switch_input(&input);
        get_next_tok();
        ex ret = parse_expression();
+       // parse_expression() stops if it encounters an unknown token.
+       // This is not a bug: since the parser is recursive checking
+       // whether the next token is valid is responsibility of the caller.
+       // Hence make sure nothing is left in the stream:
+       if (token != lexer::token_type::eof)
+               Parse_error("expected EOF");
+
        return ret;
 }