// See https://www.gnu.org/software/bison/manual/html_node/Calc_002b_002b-Parsing-Driver.html #include "driver.hh" #include "parser.hh" driver::driver () : trace_parsing (false), trace_scanning (false) { // These are hardcoded variables that are now available inside expressions you write // e.g. 'y = one + 1' variables["one"] = 1; variables["two"] = 2; } int driver::parse (const std::string &f) { file = f; location.initialize (&file); // set location to beginning of file or stdin scan_begin (); yy::parser parse (*this); // set the parsing context to *this (remember, we are inside driver.cc class) parse.set_debug_level (trace_parsing); int res = parse (); //this evaluates the file (or stdin, see scan_begin() definition at the end of scanner.ll) scan_end (); return res; }