fork download
  1. %{
  2. #include<stdio.h>
  3. %}
  4.  
  5. %%
  6. auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while {printf("%s is a keyword\n",yytext);}
  7. [+*/=<>^-] {printf("%s is a operator\n",yytext);}
  8. [a-zA-Z_][a-zA-Z0-9_]* {printf("%s is an identifier\n",yytext);}
  9. [0-9]+ {printf("%s is a number\n",yytext);}
  10. [a-zA-Z_0-9!@#$&]+ {printf("%s is an text\n",yytext);}
  11. [,:;(){}?!|&`~] {printf("%s is a punctuation\n",yytext);}
  12.  
  13. [\t|\n];
  14. %%
  15.  
  16. int main()
  17. {
  18. printf("Enter string: ");
  19. yylex();
  20. }
  21.  
  22. int yywrap()
  23. {
  24. return 1;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6880KB
stdin
hi void bbi9
stdout
Standard output is empty
stderr
ERROR: /home/16joIR/prog:2:1: Syntax error: End of file in quoted codes
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit