fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. [0-9]+ { printf("NUMBER: %s\n", yytext); }
  7. [a-zA-Z]+ { printf("WORD: %s\n", yytext); }
  8. [ \t\n]+ { /* ignore whitespace */ }
  9. . { printf("OTHER: %s\n", yytext); }
  10. %%
  11.  
  12. int main(void)
  13. {
  14. printf("Enter some text:\n");
  15. yylex(); // start lexical analysis
  16. return 0;
  17. }
  18.  
  19. int yywrap(void)
  20. {
  21. return 1;
  22. }
  23.  
Success #stdin #stdout #stderr 0.02s 6980KB
stdin
Hello 123 !
stdout
Standard output is empty
stderr
ERROR: /home/vkhY34/prog:2:1: Syntax error: Operator expected
ERROR: /home/vkhY34/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? EOF: exit