Advertisement
vvccs

Untitled

Jul 31st, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. %{
  2. #include<stdio.h>
  3. %}
  4. %%
  5. [0-9]+[.][0-9]+ printf("%s is a floating point number\n",yytext);
  6. int|float|char|double|voidprintf("%s is a datatype\n",yytext);
  7. [0-9]+ printf("%s is an integer number\n",yytext);
  8. [a-z]+[()] printf("%s is a function\n",yytext);
  9. [a-z]+ printf("%s is an identifier\n",yytext);
  10. [+=*/-] printf("%s is an operator\n",yytext);
  11. printf("%s is an delimiter\n",yytext);
  12. printf("%s is a separator\n",yytext);
  13. [#][a-z\.h]+ printf("%s is a preprocessor\n",yytext);
  14. %%
  15. intyywrap(void) {}
  16. int main()
  17. {
  18. // reads input from a file named test.c rather than terminal
  19. freopen("test.c", "r", stdin);
  20. yylex();
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement