-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_prog.l
29 lines (24 loc) · 866 Bytes
/
c_prog.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%option noyywrap
%{
#include<stdio.h>
%}
%%
"{" {printf("Open Brace : %s\n",yytext);}
"}" {printf("Close Brace : %s\n",yytext);}
"int" {printf("Datetype : %s\n",yytext);}
"=" {printf("Assignment op : %s\n",yytext);}
":" {printf("Colon : %s\n",yytext);}
"printf" {printf("Function : %s\n",yytext);}
[a-zA-Z0-9_][a-zA-Z]* {printf("Identifier : %s\n",yytext);}
[0-9_]+ {printf("Number : %s\n",yytext);}
"(" {printf("left paren : %s\n",yytext);}
")" {printf("right paren : %s\n",yytext);}
"," {printf("Comma : %s\n",yytext);}
[\t] ; //ignore white sapces
. ; // ignore all other chars
%%
int main(){
yyin = stdin;
yylex();
return 0;
}