%union
{
    int
        i;
    size_t/*unsigned*/
        u;
    std::string
        *s;
};

%type<i>
    NUMBER
    number

%class-name Parser
%filenames parser
%parsefun-source parse.cc
%debug

%token NUMBER

%%

startrule:
    expressions
    'q'
    {
        cout << "Done\n";
        ACCEPT();
    }
;

expressions:
    expressions
    expression
|
    expression
;

expression:
    number
    '+'
    number
    '='
    {
        cout << $1 << " + " << $3 << " = " << $1 + $3 << endl;
    }
;

number:
    NUMBER
    {
        $$ = atoi(d_scanner.YYText());
        cout << "Saw " << d_scanner.YYText() << endl;
    }
;



