Untitled
unknown
plain_text
a year ago
997 B
12
Indexable
%{
#include <stdio.h>
int state = 0; // Declare state variable
%}
%%
start { state = 0; }
"a" {
if (state == 0) state = 1;
else if (state == 1 || state == 2 || state == 3 || state == 4) state = 1;
}
"b" {
if (state == 0) state = 0;
else if (state == 1) state = 2;
else if (state == 2 || state == 3) state = 0;
else if (state == 4) state = 4;
}
"ab" {
if (state == 1) state = 2;
else if (state == 2 || state == 3) state = 3;
else if (state == 4) state = 4;
}
"abb" {
if (state == 3) state = 4;
}
\n { printf("Input accepted\n"); state = 0; }
. { printf("Input rejected\n"); state = 0; }
%%
int main() {
yylex();
return 0;
}
Editor is loading...
Leave a Comment