//HEAD
%filenames parser
%scanner                ../scanner/scanner.h
%baseclass-preinclude   ../spsembase/spsembase.h
%stype                  spSemBase

%token INT IDENT 
//=
%%

//RULES
rules:
    rules rule
|
    rule
;
//=

//INT
int:
    INT
    {
        $$ = new Semantic<Tag::INT>(A2x(d_scanner.matched()).to<int>());
    }
;

ident:
    IDENT
    {
        $$ = new Semantic<Tag::TEXT>(d_scanner.matched());
    }
;
//=

//ARGS
value:
    int
|
    ident
;

arglist:
    arglist ',' value
    {
        $1->as<Tag::VECTOR>().push_back($3);
    }
|
    value
    {
        $$ = new Semantic<Tag::VECTOR>(
                        vector<shared_ptr<SemBase const>> {$1});
    }
;
//=

//RULE
rule:
    ident '(' arglist ')' ';'
    {
        display($1, $3);
    }
|
    ident '=' int ';'
    {
          cout << $1->as<Tag::TEXT>() << " = " << $3->as<Tag::INT>() << ";\n";
    }
;
//=

