fork download
  1. /*lex program to find the length of a string*/
  2.  
  3. %{
  4. #include<stdio.h>
  5. int length;
  6. %}
  7.  
  8. /* Rules Section*/
  9. %%
  10. [a-z A-Z 0-9]+ {length=yyleng; }
  11. %%
  12.  
  13. int main()
  14. {
  15. yylex();
  16. printf("length of given string is : %d", length);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout #stderr 0.02s 6888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ba3J9x/prog:18:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit