view parser.h @ 12:894be158b32d

define parser as a class and eliminate some global variables
author John W. Eaton <jwe@octave.org>
date Thu, 23 May 2019 17:57:20 -0400
parents 0e154787183d
children d179b0bb85e4
line wrap: on
line source

#if ! defined (calc_parse_h)
#define calc_parse_h 1

namespace calc
{
  class interpreter;

  class parser
  {
  public:

    parser (interpreter&);

    parser (const parser&) = delete;

    parser& operator = (const parser&) = delete;

    ~parser (void);

    bool beg_of_stmt (void) const { return m_beg_of_stmt; }

    void beg_of_stmt (bool flag) { m_beg_of_stmt = flag; }

    int parse_and_execute (const std::string& line);

    void emit_error (const char *msg) const;

    void emit_result (double value) const;

  private:

    interpreter& m_interpreter;

    void *m_parser_state;

    bool m_beg_of_stmt;
  };
}

#endif