-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_progr.l
28 lines (23 loc) · 919 Bytes
/
c_progr.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
%option noyywrap
%{
#include<stdio.h>
%}
%%
"{" {printf("Open_Brace : %s\n",yytext);}
"}" {printf("Close_Brace : %s\n",yytext);}
"int"|"float" {printf("DataType : %s\n",yytext);}
[0-9_]+ {printf("Number : %s\n",yytext);}
";" {printf("Semicolon : %s\n",yytext);}
"*" {printf("Multiply : %s\n",yytext);}
"+" {printf("addition : %s\n",yytext);}
"(" {printf("Open Paren : %s\n",yytext);}
")" {printf("Close Paren : %s\n",yytext);}
"," {printf("Comma : %s\n",yytext);}
"=" {printf("Assignment : %s\n",yytext);}
[a-zA-Z_][a-zA-Z0-9_]* {printf("Identifier : %s\n",yytext);}
%%
int main(){
yyin = stdin;
yylex();
return 0;
}