Calculator  Step 1
parse.hpp
Go to the documentation of this file.
1 #ifndef PARSE_HPP_
2 #define PARSE_HPP_
3 
4 #include <istream>
5 #include <locale>
6 #include <ostream>
7 #include <stdexcept>
8 #include <string>
9 
11 class parse_error : public std::runtime_error {
12 public:
13  parse_error(std::string const& msg) : runtime_error{msg} {}
14 };
15 
17 class parser
18 {
19 public:
23  parser(std::istream& input);
24 
30  bool get_expr(double& result);
31 
32 private:
37  std::string charify(char c);
42  bool get_number(double& result);
48  bool get_primary(double& result);
53  bool get_mult_expr(double& result);
54 
55  std::istream& input_;
56  std::ctype<char> const& ctype_;
57 };
58 
64 void parse_loop(std::istream& input, std::ostream& output);
65 
66 #endif
bool get_primary(double &result)
Definition: parse.cpp:162
void parse_loop(std::istream &input, std::ostream &output)
Definition: parse.cpp:183
parser(std::istream &input)
Definition: parse.cpp:6
parse_error(std::string const &msg)
Definition: parse.hpp:13
std::string charify(char c)
Definition: parse.cpp:11
bool get_number(double &result)
Definition: parse.cpp:38
Definition: parse.hpp:17
bool get_expr(double &result)
Definition: parse.cpp:110
std::istream & input_
Definition: parse.hpp:55
std::ctype< char > const & ctype_
Definition: parse.hpp:56
bool get_mult_expr(double &result)
Definition: parse.cpp:135