fork download
  1. %{
  2. /* Declarations */
  3. int wordCount = 0;
  4. int lineCount = 0;
  5. %}
  6.  
  7. %%
  8. [a-zA-Z]+ { wordCount++; } /* Count words */
  9. \n { lineCount++; } /* Count newlines */
  10. . ; /* Ignore all other characters */
  11.  
  12. %%
  13. int main() {
  14. yylex();
  15. printf("Number of words: %d\n", wordCount);
  16. printf("Number of lines: %d\n", lineCount);
  17. return 0;
  18. }
  19.  
  20. int yywrap() {
  21. return 1;
  22. }
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ntLzF0/prog:3:4: Syntax error: Operator expected
ERROR: /home/ntLzF0/prog:22:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit