From 39410a12a3b0c21f8378149d5e29088f6ca7f4e3 Mon Sep 17 00:00:00 2001 From: serr Date: Tue, 13 May 2025 18:58:28 +0300 Subject: [PATCH] =?UTF-8?q?import=20=D0=BC=D0=BE=D0=B6=D0=B5=D1=82=20?= =?UTF-8?q?=D0=B1=D1=8B=D1=82=D1=8C=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=B8=20=D0=B5=D0=B3=D0=BE=20=D0=BC=D0=BE=D0=B6=D0=B5=D1=82?= =?UTF-8?q?=20=D0=B2=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=20=D0=BD=D0=B5=20=D0=B1?= =?UTF-8?q?=D1=8B=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analyzers/test/test.y | 8 ++++++-- tests/test.txt | 3 ++- tests/test_blocks.txt | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/analyzers/test/test.y b/analyzers/test/test.y index 7195f42..fdccd53 100644 --- a/analyzers/test/test.y +++ b/analyzers/test/test.y @@ -76,7 +76,6 @@ math_expr: | IDENTIFIER { printf("IDENTIFIER: %s\n", $1); } ; -/* Остальные правила остаются без изменений */ int_types: UINT { } | UINT8 { } @@ -112,7 +111,8 @@ package_declaration: ; import_declaration: - IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } import { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } + | IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } LPAREN RPAREN { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } + | IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } import { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } | IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } LPAREN import_list RPAREN { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } ; @@ -126,6 +126,7 @@ import_list: ; // +// functions decl arg_declaration: IDENTIFIER type { printf("\033[1;35mARG: %s\n\033[0m", $1); } @@ -146,7 +147,9 @@ func_declaration: LPAREN arg_list RPAREN return_type block { printf("\033[1;35mBY, FUNC: %s\n\n\033[0m", $2); } ; +// +// vars decl var_declaration: IDENTIFIER SHORT_DECLARATION math_expr { printf("\033[1;33mSHORT DECL with math expr: %s\n\033[0m", $1); } | IDENTIFIER SHORT_DECLARATION literal { printf("\033[1;33mSHORT DECL with literal: %s\n\033[0m", $1); } @@ -156,6 +159,7 @@ var_declaration: ; %% +// int main(int argc, char **argv) { if (argc > 1) { diff --git a/tests/test.txt b/tests/test.txt index 9566e6e..3901d20 100644 --- a/tests/test.txt +++ b/tests/test.txt @@ -17,7 +17,8 @@ func test(a int, b string) { func main() { - var a int; + var b int; + var a int = 2; a = 2+2*2-(1+10); a = a + 1; a = a; diff --git a/tests/test_blocks.txt b/tests/test_blocks.txt index f4da731..14c0f50 100644 --- a/tests/test_blocks.txt +++ b/tests/test_blocks.txt @@ -1,3 +1,4 @@ +package main; func test_func(a string, b int, c uint16) int { var x int = 42;