X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fparser%2Fparser.cpp;h=6411ba1416e740a85705ceee3153815b33e9364f;hp=6cac523c38625d8bddad69dcbc648d4b629665c4;hb=1261c54df6548cf558405a118b2134805f63376d;hpb=d4593e1981a168677f98e4d3b098696bd31088e2 diff --git a/ginac/parser/parser.cpp b/ginac/parser/parser.cpp index 6cac523c..6411ba14 100644 --- a/ginac/parser/parser.cpp +++ b/ginac/parser/parser.cpp @@ -138,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; }