]> www.ginac.de Git - ginac.git/blobdiff - ginac/parser/lexer.cpp
parser: improve error reporting a little bit.
[ginac.git] / ginac / parser / lexer.cpp
index ed1f894fea381bdc9c553d9a2811ff12b1697bcb..d8c49b8cf4b35da972b19074b506aa0380c3725e 100644 (file)
@@ -126,6 +126,21 @@ void lexer::switch_input(std::istream* in)
        input = in;
        line_num = 0;
        column = 0;
+       c = ' ';
+}
+
+/// Symbolic name of current token (for error reporting)
+std::string lexer::tok2str(const int tok) const
+{
+       switch (tok) {
+               case lexer::token_type::identifier:
+               case lexer::token_type::number:
+                       return std::string("\"") + str + "\"";
+               case lexer::token_type::eof:
+                       return std::string("EOF");
+               default:
+                       return std::string("\"") + char(tok) + "\"";
+       }
 }
 
 } // namespace GiNaC