Calculator Step 6

- Main Page
- Classes
- Files

- File List
- File Members

Functions
parse.cpp File Reference
`#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)

## Function Documentation

void parse_loop | ( | std::istream & | input,
|  | std::ostream & | output
| ) |  |

Parse loop. Read expressions from `input` and print results to `output`.

Parameters

  input | The input stream.
  output | The output stream.

Definition at line 444 of file parse.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and main().

445 {
446 std::string line{};
447 // No portable way to test whether the console is an interactive terminal
448 // vs. a non-interactive file. If you have a system-specific way to test,
449 // output the prompt only for the interactive case.
450 for (output << "> "; std::getline(input, line); output << "> ") {
451 std::istringstream input{std::move(line)};
452 parser p{input};
453 try {
454 while (p.get_statement(output)) {
455 /* empty */
456 }
457 } catch(calc_error const& ex) {
458 output << ex.what() << '\n';
459 } catch(std::exception const& ex) {
460 output << "exception: " << ex.what() << '\n';
461 }
462 }
463 }
calc_error
Definition: calc_error.hpp:11
parser
Definition: parse.hpp:26