#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 444 of file parse.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), and main().
00445 { 00446 std::string line; 00447 // No portable way to test whether the console is an interactive terminal 00448 // vs. a non-interactive file. If you have a system-specific way to test, 00449 // output the prompt only for the interactive case. 00450 for (output << "> "; std::getline(input, line); output << "> ") { 00451 std::istringstream input(line); 00452 parser p(input); 00453 try { 00454 while (p.get_statement(output)) { 00455 /* empty */ 00456 } 00457 } catch(calc_error const& ex) { 00458 output << ex.what() << '\n'; 00459 } catch(std::exception const& ex) { 00460 output << "exception: " << ex.what() << '\n'; 00461 } 00462 } 00463 }