From 6b921474dd811a0543aa1c178e1246043b63880c Mon Sep 17 00:00:00 2001 From: serr Date: Sun, 18 May 2025 17:04:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D1=8E=20=D1=81=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2,=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B6=D0=B5=D1=81=D1=82=D0=B2=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=83=D1=8E=20=D0=BA=D0=BE=D1=80=D0=BE=D1=82=D0=BA=D1=83?= =?UTF-8?q?=D1=8E=20=D0=B4=D0=B5=D0=BA=D0=BB=D0=B0=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analyzers/test/test.y | 14 +++++++------- tests/test_multiple_declaration.txt | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/analyzers/test/test.y b/analyzers/test/test.y index f99a05a..d75029b 100644 --- a/analyzers/test/test.y +++ b/analyzers/test/test.y @@ -89,12 +89,12 @@ identifiers_list: IDENTIFIER { } | identifiers_list COMMA IDENTIFIER { } -math_expr_and_literals_list: +math_expr_or_literals_list: literal { } - | math_expr_and_literals_list COMMA literal + | math_expr_or_literals_list COMMA literal | math_expr { } - | math_expr_and_literals_list COMMA math_expr + | math_expr_or_literals_list COMMA math_expr // // condition @@ -119,7 +119,7 @@ cicle: ; post_statement: - | identifiers_list ASSIGN math_expr_and_literals_list { } + | identifiers_list ASSIGN math_expr_or_literals_list { } | IDENTIFIER INC { } | IDENTIFIER DEC { } | IDENTIFIER PLUS_EQ math_expr { } @@ -139,8 +139,8 @@ loop_block: ; init_loop_statement: - | identifiers_list SHORT_DECLARATION math_expr_and_literals_list - | identifiers_list ASSIGN math_expr_and_literals_list + | identifiers_list SHORT_DECLARATION math_expr_or_literals_list + | identifiers_list ASSIGN math_expr_or_literals_list loop_statements: | loop_statements statement @@ -304,7 +304,7 @@ func_declaration: // vars decl var_multiple_short_declaration: - identifiers_list SHORT_DECLARATION math_expr_and_literals_list + identifiers_list SHORT_DECLARATION math_expr_or_literals_list var_declaration: VAR IDENTIFIER type { { printf("\033[1;33mVAR DECL without init value: %s\n\033[0m", $2); } } diff --git a/tests/test_multiple_declaration.txt b/tests/test_multiple_declaration.txt index 647ee9c..0ebacaf 100644 --- a/tests/test_multiple_declaration.txt +++ b/tests/test_multiple_declaration.txt @@ -8,6 +8,7 @@ func test() { a, b := "hello", "sailor"; // декларация нескольких переменных (строковые литералы) a, b, c, d := "hello", 2, 3.123, true; // декларация нескольких переменных (всякое) + // цикл с множественной декларацией и множественным присвоением for k, l := 0, 10; k < l; k, l = k+1, l-1 { }