Skip to content

Commit 6628880

Browse files
Create 1a.c
0 parents  commit 6628880

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1a.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
%{
2+
#include<stdio.h>
3+
int v=0,op=0,id=0,flag=0;
4+
%}
5+
%%
6+
[a-zA-Z]+[0-9A-Za-z]* {id++;printf("\n Identifier:");ECHO;}
7+
[\+\-\*\/\=] {op++;printf("\n Operartor:");ECHO;}
8+
"(" {v++;}
9+
")" {v--;}
10+
";" {flag=1;}
11+
.|\n {;}
12+
%%
13+
main()
14+
{
15+
printf("Enter the expression");
16+
yylex();
17+
if((op+1) ==id && v==0 && flag==0)
18+
printf("\n Expression is Valid\n");
19+
else
20+
printf("\n Expression is Invalid\n");
21+
}

0 commit comments

Comments
 (0)