comments added
parent
46e0aaa1bf
commit
ca95ce2a3f
|
@ -35,6 +35,23 @@ void yyerror(const char *s) {
|
||||||
"while" { return WHILE; }
|
"while" { return WHILE; }
|
||||||
"if" { return IF; }
|
"if" { return IF; }
|
||||||
"else" { return ELSE; }
|
"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; }
|
[0-9]+ { yylval.str = strdup(yytext); return NUMBER; }
|
||||||
[a-zA-Z_][a-zA-Z0-9_]* { yylval.str = strdup(yytext); return IDENTIFIER; }
|
[a-zA-Z_][a-zA-Z0-9_]* { yylval.str = strdup(yytext); return IDENTIFIER; }
|
||||||
[ \t] ;
|
[ \t] ;
|
||||||
|
|
14
code.txt
14
code.txt
|
@ -1,30 +1,32 @@
|
||||||
{
|
{
|
||||||
|
// 123123132
|
||||||
|
/* test */
|
||||||
x = 2 + 1 % 1;
|
x = 2 + 1 % 1;
|
||||||
|
|
||||||
if (!x && 1 || (x + (-100))) {
|
if (!x && 1 || (x + (-100))) { // comment
|
||||||
x = 3;
|
x = 3;
|
||||||
if (x) {
|
if (x) {
|
||||||
x = 5;
|
x = 5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
x = 5;
|
x = 5; // comment
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x) {
|
if (x) {
|
||||||
x = 3;
|
x = 3; // comment
|
||||||
}
|
}
|
||||||
|
|
||||||
x = z + 3 + 5;
|
x = z + 3 + 5; // comment
|
||||||
{
|
{
|
||||||
x = -10;
|
x = -10;
|
||||||
y = (x + +5) % 2;
|
y = (x + +5) % 2;
|
||||||
while (x + 1) {
|
while (x + 1) {
|
||||||
z = y * +2 / -(5 * ( ((3)) ));
|
z = y * +2 / -(5 * ( ((3)) )); /* comment*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print x;
|
print x;
|
||||||
while (1) {
|
while (1) {
|
||||||
x = x + 1;
|
x = x + 1;
|
||||||
}
|
}
|
||||||
return x / 2 + 5;
|
return x / 2 + 5; /* comment*//* comment*//* comment*/
|
||||||
}
|
}
|
Loading…
Reference in New Issue