Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %start ZERO ONE
- %{
- #include <stdio.h>
- char *ans[] = {"Correct", "Incorrect"};
- %}
- %%
- <ZERO>0\n return 1;
- <ZERO>1\n return 0;
- <ZERO>1 BEGIN ONE;
- <ZERO>0 ;
- <ONE>1\n return 1;
- <ONE>0\n return 0;
- <ONE>0 BEGIN ZERO;
- <ONE>1 ;
- 0 BEGIN ZERO;
- 1 BEGIN ONE;
- .|\n return 1;
- %%
- int main(int argc, char *argv[])
- {
- int ret = yylex();
- printf("%s bin set\n", ans[ret]);
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement