Mercurial > hg > Members > nobuyasu > SampleSource
diff Bison-Flex/CALC/Bison-Flex/EUC/calc-driver.h @ 0:db40c85cad7a default tip
upload sample source
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 May 2011 03:11:59 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bison-Flex/CALC/Bison-Flex/EUC/calc-driver.h Mon May 09 03:11:59 2011 +0900 @@ -0,0 +1,46 @@ +#ifndef __CALC_DRIVER_H__ +#define __CALC_DRIVER_H__ + +#include "calc-parser.hh" +#include "node.h" + +// Forward declarations. +class calc_driver; + +#define YY_DECL \ + yy::calc_parser::token_type \ + yylex(yy::calc_parser::semantic_type* yylval, \ + calc_driver& driver) + +YY_DECL; + +class calc_driver { + public: + calc_driver(); + virtual ~calc_driver(); + + std::string &get_filename() { return file; } + bool calc(const std::string &f); + + int value(const std::string *name) + { + return values[*name]; + } + void assign(const std::string *value, cnode *node); + void print(cnode *node); + void list(); + + // Error handling. + void error(const std::string& m); + + private: + void scan_begin(); + void scan_end(); + + private: + std::map<std::string, int> values; // 変数テーブル + + std::string file; +} ; + +#endif