%{ #include<stdio.h> #include<string.h> int n = 0 ; %} %% "while"|"if"|"else" {n++;printf("\t keywords : %s", yytext);} "int"|"float" {n++;printf("\t keywords : %s", yytext);} [a-zA-Z_][a-zA-Z0-9_]* {n++;printf("\t identifier : %s", yytext);} "<="|"=="|"="|"++"|"-"|"*"|"+" {n++;printf("\t operator : %s", yytext);} [(){}|, ;] {n++;printf("\t separator : %s", yytext);} [0-9]*"."[0-9]+ {n++;printf("\t float : %s", yytext);} [0-9]+ {n++;printf("\t integer : %s", yytext);} "\n" {printf("\n total no. of token = %d\n", n);} %% int yywrap(void){} int main() { yylex(); printf("check"); return 0; }
Comments
Post a Comment