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