fork download
  1. %{
  2. #include<stdio.h>
  3. int i = 0;
  4. %}
  5.  
  6. /* Rules Section */
  7. %%
  8. [a-zA-Z0-9]+ { i++; } /* Rule for counting words (alphanumeric sequences) */
  9. \n { printf("Number of words: %d\n", i); i = 0; } /* Output word count at end of each line */
  10. %%
  11.  
  12. int yywrap(void) {
  13. return 1; /* Required function that can just return 1 */
  14. }
  15.  
  16. int main() {
  17. yylex(); /* Start lexical analysis */
  18. return 0;
  19. }
  20.  
Success #stdin #stdout #stderr 0.02s 6928KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/eKjSGx/prog:19:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit