#include <cstdlib>
#include <iterator>
#include <sstream>
#include "calc_error.hpp"
#include "node.hpp"
#include "parse.hpp"
#include "variables.hpp"
Go to the source code of this file.
Functions | |
void | parse_loop (std::istream &input, std::ostream &output) |
void parse_loop | ( | std::istream & | input, | |
std::ostream & | output | |||
) |
Parse loop. Read expressions from input
and print results to output
.
input | The input stream. | |
output | The output stream. |
Definition at line 338 of file parse.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), and main().
00339 { 00340 std::string line; 00341 // No portable way to test whether the console is an interactive terminal 00342 // vs. a non-interactive file. If you have a system-specific way to test, 00343 // output the prompt only for the interactive case. 00344 for (output << "> "; std::getline(input, line); output << "> ") { 00345 std::istringstream input(line); 00346 parser p(input); 00347 try { 00348 while (p.get_statement(output)) { 00349 /* empty */ 00350 } 00351 } catch(calc_error const& ex) { 00352 output << ex.what() << '\n'; 00353 } catch(std::exception const& ex) { 00354 output << "exception: " << ex.what() << '\n'; 00355 } 00356 } 00357 }