fork download
  1. %option noyywrap
  2. %{
  3. #include<stdio.h>
  4. %}
  5. ws [ \t]+
  6. string \"[^\n"]+\"
  7. digits [0-9]
  8. letter [a-zA-Z]
  9. alphanum [a-zA-Z0-9]
  10. operator [+|-|*|/|%|=]
  11. %%
  12. {ws} /* skip blanks and tabs */
  13. (int|char|float|double|if|for) printf("\n keyword: %s ", yytext);
  14. {digits}*\.{digits}+ printf("\n float number: %s ", yytext);
  15. (-|\+)*{digits}+ printf("\n int number: %s ", yytext);
  16. {letter}(_|{alphanum})* printf("\n identifer: %s ", yytext);
  17. {string} printf("\n string: %s ",yytext);
  18. {operator} printf("\n operator: %s ",yytext);
  19. '.' printf("\n character: %s ", yytext);
  20. . {
  21.  
  22. printf("\n Special symbols: %s ", yytext);
  23. }
  24.  
  25. %%
  26. int main()
  27. {
  28. printf("\n Enter input program:");
  29. yylex();
  30. return 0;
  31. }
Success #stdin #stdout #stderr 0.03s 6784KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/aFyZ5Q/prog:3:1: Syntax error: Operator expected
ERROR: /home/aFyZ5Q/prog:31:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit