Mercurial > jwe > qt-gui-with-push-parser
diff interpreter.h @ 12:894be158b32d
define parser as a class and eliminate some global variables
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 May 2019 17:57:20 -0400 |
parents | 04867eba6428 |
children | 1e5a1e15fa56 |
line wrap: on
line diff
--- a/interpreter.h Thu May 23 13:42:57 2019 -0400 +++ b/interpreter.h Thu May 23 17:57:20 2019 -0400 @@ -3,6 +3,8 @@ #include <functional> +#include "parser.h" + namespace calc { class interpreter @@ -17,7 +19,9 @@ interpreter& operator = (const interpreter&) = delete; - ~interpreter (void); + ~interpreter (void) = default; + + parser& get_parser (void) { return m_parser; } int parse_and_execute (const std::string& line); @@ -37,12 +41,14 @@ return tmp; } - void emit_error (const char *msg); + void emit_error (const char *msg) const; - void emit_result (double value); + void emit_result (double value) const; private: + parser m_parser; + std::function<void (const char *)> m_error_handler; std::function<void (double)> m_result_handler; };