fork download
  1.  
  2. Sameer Khan <sameer654khan654@gmail.com>
  3. 14:29 (4 minutes ago)
  4. to rajeevsharma9808
  5.  
  6. %{
  7. #include<stdio.h>
  8. #include<string.h>
  9. %}
  10.  
  11. %%
  12. "int"|"float"|"char"|"double" { printf("Keyword: %s\n", yytext); }
  13. [0-9]+ { printf("Number: %s\n", yytext); }
  14. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
  15. "+"|"-"|"*"|"/" { printf("Operator: %s\n", yytext); }
  16. "=" { printf("Assignment Operator: %s\n", yytext); }
  17. ";" { printf("Semicolon\n"); }
  18. [ \t\n]+ { /* Ignore whitespace */ }
  19. . { printf("Invalid: %s\n", yytext); }
  20. %%
  21.  
  22. int main()
  23. {
  24. printf("Enter the input:\n");
  25. yylex();
  26. return 0;
  27. }
  28.  
  29. int yywrap()
  30. {
  31. return 1;
  32. }
Success #stdin #stdout #stderr 0.02s 6776KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/MMTTW3/prog:2:7: Syntax error: Operator expected
ERROR: /home/MMTTW3/prog:32:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit