fork download
  1. %{
  2. #include <stdio.h>
  3. int chars=0,words=0,newLine=0,space=0;
  4. %}
  5. %%
  6. [a-zA-Z]+ {words++; chars+=yyleng;}
  7. [ ] {space++;}
  8. [\n] {newLine++;}
  9. %%
  10. int yywrap(){
  11. return 1;
  12. }
  13. int main(){
  14. printf("Enter String: ");
  15. //This will be called when takin in the inout and calling the whole thing defined
  16. inside the %% %%
  17. yylex();
  18. printf("Characters: %d\n",chars);
  19. printf("Words: %d\n",words);
  20. printf("Spaces: %d\n",space);
  21. printf("New Lines: %d\n",newLine);
  22. }
Success #stdin #stdout #stderr 0.03s 6964KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/lRQsyD/prog:22:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit