summaryrefslogtreecommitdiffstats
path: root/src/lib/eval/eval_context.h
diff options
context:
space:
mode:
authorTomek Mrugalski <tomasz@isc.org>2015-10-28 20:13:59 +0100
committerTomek Mrugalski <tomasz@isc.org>2015-10-30 14:20:11 +0100
commit28413e825867f485cb1fa7fa75861edacddf5335 (patch)
tree280ceab2620f8c67cb27768698df40154c1023d6 /src/lib/eval/eval_context.h
parent[4081] Stub documentation added. (diff)
downloadkea-28413e825867f485cb1fa7fa75861edacddf5335.tar.xz
kea-28413e825867f485cb1fa7fa75861edacddf5335.zip
[4088] Bison example integrated.
Diffstat (limited to 'src/lib/eval/eval_context.h')
-rw-r--r--src/lib/eval/eval_context.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/eval/eval_context.h b/src/lib/eval/eval_context.h
new file mode 100644
index 0000000000..1d26f04faa
--- /dev/null
+++ b/src/lib/eval/eval_context.h
@@ -0,0 +1,45 @@
+#ifndef CALCXX_DRIVER_HH
+# define CALCXX_DRIVER_HH
+# include <string>
+# include <map>
+# include "parser.h"
+
+// Tell Flex the lexer's prototype ...
+# define YY_DECL \
+ yy::calcxx_parser::symbol_type yylex (calcxx_driver& driver)
+
+// ... and declare it for the parser's sake.
+YY_DECL;
+
+// Conducting the whole scanning and parsing of Calc++.
+class calcxx_driver
+{
+public:
+ calcxx_driver ();
+ virtual ~calcxx_driver ();
+
+ std::map<std::string, int> variables;
+
+ int result;
+
+ // Handling the scanner.
+ void scan_begin ();
+ void scan_end ();
+ bool trace_scanning;
+
+ // Run the parser on file F.
+ // Return 0 on success.
+ int parse (const std::string& f);
+
+ // The name of the file being parsed.
+ // Used later to pass the file name to the location tracker.
+
+ std::string file;
+ // Whether parser traces should be generated.
+ bool trace_parsing;
+
+ // Error handling.
+ void error (const yy::location& l, const std::string& m);
+ void error (const std::string& m);
+};
+#endif // ! CALCXX_DRIVER_HH