fork download
  1. %{
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. %}
  5.  
  6.  
  7.  
  8. number [0-9]+
  9. identifier [a-zA-Z_][a-zA-Z0-9+]*
  10. keyword if|while|do|else|int|float|double
  11.  
  12. %%
  13.  
  14. {number} {printf("the given %d is a number",atoi(yytext));}
  15. {identifier} {printf("the given %s is a identifier",yytext);}
  16. {keyword} {printf("the given %s is a keyword",yytext);}
  17. .* {printf("the given %s is a keyword",yytext);}
  18.  
  19. %%
  20.  
  21. int main(void)
  22. {
  23. printf("enter the input");
  24. yylex();
  25. return 0;
  26. }
Success #stdin #stdout #stderr 0.03s 6956KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/UG1u0p/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit