fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4. %%
  5. [a-z|A-Z][a-z|A-Z|0-9]* { printf("Identifiers”); }
  6. [0-9]+ { printf(" constants”); }
  7. If|else|for|int {printf("keywords”); }
  8. [=|+|-|/] {printf("operators ”); }
  9. int main() {
  10. printf("Enter input: ");
  11. yylex(); // Start lexical analysis
  12. return 0;
  13. }
  14. int yywrap()
  15. {
  16. Return 1;
  17. }
Success #stdin #stdout #stderr 0.03s 6976KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/HyUDzc/prog:17:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit