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