Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include<stdio.h>
- %}
- %%
- [0-9]+[.][0-9]+ printf("%s is a floating point number\n",yytext);
- int|float|char|double|voidprintf("%s is a datatype\n",yytext);
- [0-9]+ printf("%s is an integer number\n",yytext);
- [a-z]+[()] printf("%s is a function\n",yytext);
- [a-z]+ printf("%s is an identifier\n",yytext);
- [+=*/-] printf("%s is an operator\n",yytext);
- printf("%s is an delimiter\n",yytext);
- printf("%s is a separator\n",yytext);
- [#][a-z\.h]+ printf("%s is a preprocessor\n",yytext);
- %%
- intyywrap(void) {}
- int main()
- {
- // reads input from a file named test.c rather than terminal
- freopen("test.c", "r", stdin);
- yylex();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement