Lex program for recognizing character, digit or any special character

%{
#include<stdio.h>
%}
%%
[a-z A-Z] {printf("%s-charcter \n ",yytext);}
[0-9] {printf("%s-digit \n ",yytext);}
[^a-zA-Z0-9] {printf("%s-special charcter \n ",yytext);} //not starting with
%%
int yywrap() //this functional is optional
{
return(1);
}
int main()
{
yylex();
return 0;
}

Comments

Popular posts from this blog

A program to find FIRST of non-terminals of the given grammar

Write a context free grammar for structure of a english sentence, where a pronoun is followed by a verb and verb is followed by determiner. Determiner is followed by noun and noun can be followed by noun. Statement can begin with noun or a proper noun. **following program is written for example sentence"I prefer a morning flight from New Delhi".

Desk Calculator