]> 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 894a2ad8afeef8ae484eca01274290dc00074815..d8c49b8cf4b35da972b19074b506aa0380c3725e 100644 (file)
@@ -129,5 +129,19 @@ void lexer::switch_input(std::istream* in)
        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