// Generated by Bisonc++ V4.10.00 on Mon, 27 Apr 2015 13:18:19 +0200

#ifndef Parser_h_included
#define Parser_h_included

// $insert baseclass
#include "parserbase.h"
// $insert scanner.h
#include "../scanner/scanner.h"

#include "../_a2x.h"

#undef Parser
class Parser: public ParserBase
{
    std::ostringstream d_rpn;

    // $insert scannerobject
    Scanner d_scanner;
        
    public:
        int parse();

    private:
        void display(int x);
        void display(double x);
        void done() const;

        static double d(int i) 
        {
            return i;
        }

        template <typename Type>
        Type exec(char c, Type left, Type right)
        {
            d_rpn << " " << c << " ";
            return c == '*' ? left * right : left + right;
        }

        template <typename Type>
        Type neg(Type op)
        {
            d_rpn << " n ";
            return -op;
        }

        template <typename Type>
        Type convert()
        {
            Type ret = A2x(d_scanner.matched());
            d_rpn << " " << ret << " ";
            return ret;
        }

        void reset();

        void error();                   // 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_();
        void nextToken_();
        void nextCycle_();
        void print_();
        void exceptionHandler(std::exception const &exc);
};


#endif
