From 46d1372143724965995e644509ed25dcf8eb19f8 Mon Sep 17 00:00:00 2001 From: serr Date: Sun, 18 May 2025 16:27:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=B4=D0=BD=D0=BE=D1=81=D1=82=D1=80=D0=BE=D1=87?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=B8=20=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analyzers/test/test.l | 16 ++++++++++++++++ tests/main.go | 8 +++++--- tests/test_blocks.txt | 6 ------ tests/test_multiple_declaration.txt | 6 ++++++ 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 tests/test_multiple_declaration.txt diff --git a/analyzers/test/test.l b/analyzers/test/test.l index fd58bec..08523ed 100644 --- a/analyzers/test/test.l +++ b/analyzers/test/test.l @@ -97,6 +97,22 @@ LETTER_OR_DIGIT [a-zA-Z0-9_] "..." { return DOTS; } ":" { return COLON; } +"//" { + int c; + while ((c = input()) != '\n' && c != 0); + if (c == '\n') yylineno++; +} + +"/*" { + int c, prev = 0; + while ((c = input()) != 0) { + if (c == '\n') yylineno++; + if (prev == '*' && c == '/') break; + prev = c; + } + if (c == 0) yyerror("Unterminated comment"); +} + \"([^"\\]|\\.)*\" { // правило для строк с возможность экранирования через \спецсимвол return STRING_LITERAL; } diff --git a/tests/main.go b/tests/main.go index e1a8d25..b86689e 100644 --- a/tests/main.go +++ b/tests/main.go @@ -8,7 +8,9 @@ const ( ) func main() { - for i := 5 - 3*(6-7); i < 10; i = 5 + 3 { - fmt.Println(i) - } + + a, b := 1, 2 + + fmt.Println(a, b) + } diff --git a/tests/test_blocks.txt b/tests/test_blocks.txt index c1fb84b..332f1ff 100644 --- a/tests/test_blocks.txt +++ b/tests/test_blocks.txt @@ -5,12 +5,6 @@ import ( "log"; ) - -func test_cicle() { - for {} - -} - func test_if() { if a != a{ diff --git a/tests/test_multiple_declaration.txt b/tests/test_multiple_declaration.txt new file mode 100644 index 0000000..8cd22ef --- /dev/null +++ b/tests/test_multiple_declaration.txt @@ -0,0 +1,6 @@ +package main; + +func test() { + a := 1; // декларация одной переменной + +} \ No newline at end of file