добавил комментарии однострочные и многострочные

master2
serr 2025-05-18 16:27:17 +03:00
parent 7d545e715c
commit 46d1372143
4 changed files with 27 additions and 9 deletions

View File

@ -97,6 +97,22 @@ LETTER_OR_DIGIT [a-zA-Z0-9_]
"..." { return DOTS; } "..." { return DOTS; }
":" { return COLON; } ":" { 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; return STRING_LITERAL;
} }

View File

@ -8,7 +8,9 @@ const (
) )
func main() { func main() {
for i := 5 - 3*(6-7); i < 10; i = 5 + 3 {
fmt.Println(i) a, b := 1, 2
}
fmt.Println(a, b)
} }

View File

@ -5,12 +5,6 @@ import (
"log"; "log";
) )
func test_cicle() {
for {}
}
func test_if() { func test_if() {
if a != a{ if a != a{

View File

@ -0,0 +1,6 @@
package main;
func test() {
a := 1; // декларация одной переменной
}