%filenames parser
%default-actions quiet

%scanner ../scanner/scanner.h

%token NUMBER

%%

lines:
    lines lineprompt
|
    prompt
;

lineprompt:
    line
    prompt
;

line:
    expression
|
    'q'
    {
        std::cout << "Done\n";
        ACCEPT();
    }
|
    error
;

expression:
    number
    '+'
    number
    '='
    {
        std::cout << "      " << $1 << " + " << $3 << " = " << 
                     $1 + $3 << "\n";
    }
;

number:
    NUMBER
    {
        $$ = atoi(d_scanner.matched().c_str());
    }
;

prompt:
    {
        std::cout << "? ";
    }
;
