fork download
  1. %{
  2. #include <stdio.h>
  3. int wordCount = 0, letterCount = 0;
  4. %}
  5. %%
  6. [ \t\n]+ ;
  7. [a-zA-Z]+ { wordCount++; printf("WORD: %s\n", yytext); }
  8. [a-zA-Z] { letterCount++; printf("LETTER: %s\n", yytext); }
  9. . ;
  10. %%
  11. int main(void) {
  12. printf("Enter text (Ctrl+D to finish):\n");
  13. yylex();
  14. printf("\nTotal Words: %d\nTotal Single Letters: %d\n", wordCount, letterCount);
  15. return 0;
  16. }
  17. int yywrap() { return 1; }
  18.  
Success #stdin #stdout #stderr 0.03s 6876KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/f6wkdl/prog:2:1: Syntax error: Operator expected
ERROR: /home/f6wkdl/prog:17:26: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit