From 415dfb6a0ef46577d94931a2dfe59570c53af20d Mon Sep 17 00:00:00 2001 From: bronku Date: Fri, 28 Nov 2025 12:31:42 +0100 Subject: [PATCH] attribute --- src/parser.y | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/parser.y b/src/parser.y index 5514f6b..b37619b 100644 --- a/src/parser.y +++ b/src/parser.y @@ -52,9 +52,9 @@ %right ASSIGN PLUS_ASSIGN MINUS_ASSIGN MULTIPLY_ASSIGN DIVIDE_ASSIGN MODULO_ASSIGN %right BIT_AND_ASSIGN BIT_OR_ASSIGN BIT_XOR_ASSIGN LSHIFT_ASSIGN RSHIFT_ASSIGN -// Add types for your grammar rules: %type > expr %type > stmt +%type >> args %type >> stmt_list @@ -84,10 +84,16 @@ expr: BinaryOperator(BinaryOperator::MUL), std::move($1), std::move($3)); } | L_PAREN expr R_PAREN {$$ = std::move($2); /* #todo: test for precedence*/} - | expr L_PAREN R_PAREN { $$ = std::make_unique(std::move($1), std::vector>());} - + | expr L_PAREN args R_PAREN { $$ = std::make_unique(std::move($1), std::move($3));} + | expr DOT IDENTIFIER { $$ = std::make_unique(std::move($1), $3);} ; +args: + /* empty */ { $$ = std::vector>(); } + | expr { $$ = std::vector>(); + $$.push_back(std::move($1)); } + | args COMMA expr { $1.push_back(std::move($3)); $$ = std::move($1); } + ; %% namespace yy { void parser::error(const std::string& msg)