fork download
  1. %{
  2. #include<stdio.h>
  3. #include<string.h>
  4. %}
  5.  
  6. %%
  7.  
  8. #.* {printf("\n%s is a preprocessor", yytext);}
  9.  
  10. int|float|double|long {printf("\n%s is a keyword", yytext);}
  11.  
  12. [a-zA-Z][a-zA-Z0-9]* { printf("\n%s is an identifier", yytext);}
  13.  
  14. [0-9]+ {printf("\n%s is a digit", yytext);}
  15.  
  16. [=+/*%] {printf("\n%s is an operator", yytext);}
  17.  
  18. [(){}|,;] {printf("\n%s is an end statement", yytext);}
  19.  
  20. %%
  21.  
  22. int main ()
  23. {
  24. yylex();
  25. return 0;
  26. }
  27. int yywrap(void)
  28. {
  29. }
  30.  
Success #stdin #stdout #stderr 0.03s 6972KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/fp2pi8/prog:29:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit