tuple
This commit is contained in:
parent
d294daa307
commit
140d01eac4
3 changed files with 28 additions and 2 deletions
|
|
@ -57,6 +57,7 @@
|
|||
%type <std::unique_ptr<Slice>> slice
|
||||
%type <std::unique_ptr<Stmt>> stmt
|
||||
%type <std::vector<std::unique_ptr<Expr>>> args
|
||||
%type <std::vector<std::unique_ptr<Expr>>> tuple
|
||||
%type <std::vector<std::unique_ptr<Stmt>>> stmt_list
|
||||
%type <std::vector<std::string>> params
|
||||
|
||||
|
|
@ -110,6 +111,7 @@ expr:
|
|||
| expr L_PAREN args R_PAREN { $$ = std::make_unique<Call>(std::move($1), std::move($3));}
|
||||
| expr DOT IDENTIFIER { $$ = std::make_unique<Attribute>(std::move($1), $3);}
|
||||
| L_BRACKET args R_BRACKET { $$ = std::make_unique<List>(std::move($2));}
|
||||
| L_PAREN tuple R_PAREN { $$ = std::make_unique<Tuple>(std::move($2));}
|
||||
| MINUS expr { $$ = std::make_unique<UnaryOpExpr>(UnaryOperator(UnaryOperator::NEG), std::move($2));}
|
||||
;
|
||||
|
||||
|
|
@ -131,6 +133,11 @@ args:
|
|||
| args COMMA expr { $1.push_back(std::move($3)); $$ = std::move($1); }
|
||||
;
|
||||
|
||||
tuple:
|
||||
expr { $$ = std::vector<std::unique_ptr<Expr>>();
|
||||
$$.push_back(std::move($1)); }
|
||||
| tuple COMMA expr { $1.push_back(std::move($3)); $$ = std::move($1); }
|
||||
|
||||
params:
|
||||
{ $$ = std::vector<std::string>();}
|
||||
| IDENTIFIER { $$ = std::vector<std::string>(); $$.push_back($1); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue