#include <cstdlib>
#include <istream>
#include <locale>
#include <ostream>
#include <string>
#include "calc_error.hpp"
#include "node.hpp"
Go to the source code of this file.
Classes | |
class | parser |
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 421 of file parse.cpp.
References parser::get_statement().
00422 { 00423 std::string line; 00424 // No portable way to test whether the console is an interactive terminal 00425 // vs. a non-interactive file. If you have a system-specific way to test, 00426 // output the prompt only for the interactive case. 00427 for (output << "> "; std::getline(input, line); output << "> ") { 00428 std::istringstream input(line); 00429 parser p(input); 00430 try { 00431 while (p.get_statement(output)) { 00432 /* empty */ 00433 } 00434 } catch(calc_error const& ex) { 00435 output << ex.what() << '\n'; 00436 } catch(std::exception const& ex) { 00437 output << "exception: " << ex.what() << '\n'; 00438 } 00439 } 00440 }