добавил секцию списков, сделал множественную короткую декларацию

master2
serr 2025-05-18 17:04:06 +03:00
parent 5a4714dbe5
commit 6b921474dd
2 changed files with 8 additions and 7 deletions

View File

@ -89,12 +89,12 @@ identifiers_list:
IDENTIFIER { } IDENTIFIER { }
| identifiers_list COMMA IDENTIFIER { } | identifiers_list COMMA IDENTIFIER { }
math_expr_and_literals_list: math_expr_or_literals_list:
literal { } literal { }
| math_expr_and_literals_list COMMA literal | math_expr_or_literals_list COMMA literal
| math_expr { } | math_expr { }
| math_expr_and_literals_list COMMA math_expr | math_expr_or_literals_list COMMA math_expr
// //
// condition // condition
@ -119,7 +119,7 @@ cicle:
; ;
post_statement: post_statement:
| identifiers_list ASSIGN math_expr_and_literals_list { } | identifiers_list ASSIGN math_expr_or_literals_list { }
| IDENTIFIER INC { } | IDENTIFIER INC { }
| IDENTIFIER DEC { } | IDENTIFIER DEC { }
| IDENTIFIER PLUS_EQ math_expr { } | IDENTIFIER PLUS_EQ math_expr { }
@ -139,8 +139,8 @@ loop_block:
; ;
init_loop_statement: init_loop_statement:
| identifiers_list SHORT_DECLARATION math_expr_and_literals_list | identifiers_list SHORT_DECLARATION math_expr_or_literals_list
| identifiers_list ASSIGN math_expr_and_literals_list | identifiers_list ASSIGN math_expr_or_literals_list
loop_statements: loop_statements:
| loop_statements statement | loop_statements statement
@ -304,7 +304,7 @@ func_declaration:
// vars decl // vars decl
var_multiple_short_declaration: 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_declaration:
VAR IDENTIFIER type { { printf("\033[1;33mVAR DECL without init value: %s\n\033[0m", $2); } } VAR IDENTIFIER type { { printf("\033[1;33mVAR DECL without init value: %s\n\033[0m", $2); } }

View File

@ -8,6 +8,7 @@ func test() {
a, b := "hello", "sailor"; // декларация нескольких переменных (строковые литералы) a, b := "hello", "sailor"; // декларация нескольких переменных (строковые литералы)
a, b, c, d := "hello", 2, 3.123, true; // декларация нескольких переменных (всякое) a, b, c, d := "hello", 2, 3.123, true; // декларация нескольких переменных (всякое)
// цикл с множественной декларацией и множественным присвоением
for k, l := 0, 10; k < l; k, l = k+1, l-1 { for k, l := 0, 10; k < l; k, l = k+1, l-1 {
} }