Lex Program To Check The Syntax of For Loop
Lex Code To check the syntax of For loop:-
Source code:-
2: #include<stdio.h>
3: #include<ctype.h>
4: int c;
5: %}
6: op "++"|"--"
7: rop "<"|">"|"<="|">="|"=="|"!="
8: id [a-zA-Z][a-zA-Z0-9]*
9: no [0-9]*
10: pp [\n\t" "]
11: %%
12: for\({id}=({no}|{id})\)?(,{id}=({no}|{id}))*\;({id}{rop}({id}|{no}))?\;({id}{op})?(,{id}{op})*\)\;?{pp}*\("{"(.*\n)*.*"}") {printf("correct");c=0;}
13: .* {printf("\nwrong");}
14: %%
15: main()
16: { yyin=fopen("file11.c","r");
17: yylex();
18: }
19: int yywrap()
20: {return 1;
21: }
Source code:-
1: %{
2: #include<stdio.h>
3: #include<ctype.h>
4: int c;
5: %}
6: op "++"|"--"
7: rop "<"|">"|"<="|">="|"=="|"!="
8: id [a-zA-Z][a-zA-Z0-9]*
9: no [0-9]*
10: pp [\n\t" "]
11: %%
12: for\({id}=({no}|{id})\)?(,{id}=({no}|{id}))*\;({id}{rop}({id}|{no}))?\;({id}{op})?(,{id}{op})*\)\;?{pp}*\("{"(.*\n)*.*"}") {printf("correct");c=0;}
13: .* {printf("\nwrong");}
14: %%
15: main()
16: { yyin=fopen("file11.c","r");
17: yylex();
18: }
19: int yywrap()
20: {return 1;
21: }
What should our input be?
ReplyDeleteany syntax of for loop like: for(i=1; i<=6; i++)
DeleteurobYisfu-Aurora Alejandro Cox https://wakelet.com/wake/ytiSwQ9RWAuBKM3233Nbk
ReplyDeleteinfelrabor
Vorecin-re Hector Buoy https://www.londonfurniturecompany.com/profile/marcussoleathea/profile
ReplyDeletepostcarczines
ratiAbrev-ge Keith Cvetkovic CorelDRAW
ReplyDeleteWebsite
Internet Download Manager
phyllitanel
Wigfalsupphi_1983 Sam Taylor click
ReplyDeleteclick
moordmodasam