text: // Generated by Bisonc++ V4.09.02 on Sat, 21 Mar 2015 18:33:13 +0100
  
  #ifndef MICROC_PARSER_PARSER_H
  #define MICROC_PARSER_PARSER_H
  
  #include "../ast.hpp"
  #include "parserbase.h"
  #include "../scanner/scanner.h"
  
  #include <exception>
  
  namespace microc {
  
  class parser_exception : public std::exception {
      public:
          parser_exception(int line, const std::string& matched);
          virtual const char* what() const noexcept;
          int line() const noexcept { return line_; }
          const std::string& matched() const noexcept { return matched_; }
  
      private:
          int line_;
          std::string matched_;
          std::string what_;
  };
  
  #undef Parser
  class Parser: public ParserBase {
      Scanner d_scanner;
      ast::Program d_prog;
  
      public:
          explicit Parser(std::istream &in = std::cin): d_scanner(in) {}
          ast::Program& prog() { return d_prog; }
          int parse();
  
      private:
          void error(char const *msg);    // called on (syntax) errors
          int lex();                      // returns the next token from the
                                          // lexical scanner.
          void print();                   // use, e.g., d_token, d_loc
  
          // support functions for parse():
          void executeAction(int ruleNr);
          void errorRecovery();
          int lookup(bool recovery);
          void nextToken();
          void print__();
          void exceptionHandler__(std::exception const &exc);
  
          int sanitizeIntegerToken(const std::string&);
          char sanitizeCharacterToken(const std::string&);
          std::string sanitizeStringToken(const std::string&);
  };
  
  } // namespace microc
  
  #endif // MICROC_PARSER_PARSER_H
  