Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- //ONLY LEX FILE
- //lex only.l
- //cc lex.yy.c -ll
- #include<stdio.h>
- #include<stdlib.h>
- void yyerror(char*);
- %}
- %%
- [0-9]* { printf("\nInteger: %s", yytext); }
- [ \t]* { printf("\nSpace"); }
- [a-zA-Z]* { printf("\nAlphabet: %s", yytext); }
- "(" { printf("\nOpen"); }
- ")" {printf("\nClosed"); }
- . {printf("\n %s was not recognized!", yytext);}
- ">end" { printf("\nBye"); exit(0);}
- %%
- int main() {
- printf("Enter something : \n");
- yylex();
- }
- int yywrap(){
- return 1;
- }
- void yyerror(char *S)
- {
- fprintf(stderr, "%s\n", S);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement