fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. DIGIT [0-9]
  6. ID [a-zA-Z_][a-zA-Z0-9_]*
  7.  
  8. %%
  9. " " ;
  10. \n ;
  11. {DIGIT}+ {printf("NUMBER: %s\n", yytext); }
  12. {ID} {printf("IDENTIFIER: %s\n", yytext); }
  13. "+"|"-"|"*"|"/" {printf("OPERATOR: %s\n", yytext); }
  14. . { printf("OTHER: %s\n", yytext); }
  15. %%
  16.  
  17. int main() {
  18. yylex();
  19. return 0;
  20. }
  21.  
  22. int yywrap() {
  23. return 1;
  24. }
  25.  
Success #stdin #stdout #stderr 0.02s 6956KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/BOzI47/prog:2:1: Syntax error: Operator expected
ERROR: /home/BOzI47/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit