Posts

Showing posts with the label Imlementation of lexical analyzer

Implementation of Lexical Analyzer

%{ int lc=0; %} %% printf printf("\nPrintf found at line no. %d",lc); scanf  printf("\nScanf found at line no. %d",lc); if | else | while | do | switch | case | for | return printf("\n%s Keyword found at line no. %d ",yytext,lc); "void main" printf("\n%s Keyword found at line no. %d ",yytext,lc); \"[^"]*\" printf("\nQuoted string found at line no. %d",lc); #include | #include<stdio.h> printf("\nHeader found at line no. %d",lc); int | float | char | double | long printf("\n%s Datatype found at line no. %d",yytext,lc); ";" | "," | ":" | "{" | "}" | "(" | ")" | "." printf("\n%s Punctuation Symbol found at line no. %d",yytext,lc); [a-z]+[a-z,0-9]* printf("\n %s Variable found at line no. %d\n",yytext,lc); [0-9]+ printf("\n%s Number found at l...