comments added

master
serr 2025-04-01 20:14:12 +03:00
parent 46e0aaa1bf
commit ca95ce2a3f
2 changed files with 29 additions and 10 deletions

View File

@ -35,6 +35,23 @@ void yyerror(const char *s) {
"while" { return WHILE; }
"if" { return IF; }
"else" { return ELSE; }
"//" {
int c;
while ((c = input()) != '\n' && c != 0); // Используем input() вместо yyinput()
if (c == '\n') line_number++;
}
"/*" {
int c, prev = 0;
while ((c = input()) != 0) { // Используем input() вместо yyinput()
if (c == '\n') line_number++;
if (prev == '*' && c == '/') break;
prev = c;
}
if (c == 0) yyerror("Unterminated comment");
}
[0-9]+ { yylval.str = strdup(yytext); return NUMBER; }
[a-zA-Z_][a-zA-Z0-9_]* { yylval.str = strdup(yytext); return IDENTIFIER; }
[ \t] ;

View File

@ -1,30 +1,32 @@
{
// 123123132
/* test */
x = 2 + 1 % 1;
if (!x && 1 || (x + (-100))) {
if (!x && 1 || (x + (-100))) { // comment
x = 3;
if (x) {
x = 5;
}
} else {
x = 5;
x = 5; // comment
}
if (x) {
x = 3;
x = 3; // comment
}
x = z + 3 + 5;
x = z + 3 + 5; // comment
{
x = -10;
y = (x + +5) % 2;
while (x + 1) {
z = y * +2 / -(5 * ( ((3)) ));
z = y * +2 / -(5 * ( ((3)) )); /* comment*/
}
}
print x;
while (1) {
x = x + 1;
}
return x / 2 + 5;
return x / 2 + 5; /* comment*//* comment*//* comment*/
}