fork download
  1. % option noyywrap
  2. %{
  3. int len=0;
  4. #include<stdio.h>
  5. %}
  6.  
  7. // Rules to identify if a character apart from alphabets
  8. // occurs in a string
  9.  
  10. %%
  11. [a-zA-Z]+ {printf("No character other than alphabets");}
  12.  
  13. /* here . will match any other character than alphabets
  14.  because alphabets are already matched above
  15.  * will matches 0 or more characters in front of it.
  16. */
  17.  
  18. .* {printf("character other than alphabets present"); }
  19. %%
  20.  
  21. // code section
  22.  
  23. int main()
  24. {
  25. yylex();
  26. return 0;
  27. }
  28.  
Success #stdin #stdout #stderr 0.03s 6828KB
stdin
a
stdout
Standard output is empty
stderr
ERROR: /home/jplRfO/prog:27:2: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit