fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. %}
  5.  
  6. ID [a-zA-Z_][a-zA-Z0-9_]*
  7.  
  8. %%
  9. "struct"[ \t]+{ID} { printf("Structure : %s\n", yytext); }
  10.  
  11. {ID}"(".*")" { printf("Function : %s\n", yytext); }
  12.  
  13. {ID}"["[0-9]+"]" { printf("Array : %s\n", yytext); }
  14.  
  15. {ID} { printf("Variable : %s\n", yytext); }
  16.  
  17. [ \t\n]+ ;
  18.  
  19. . { printf("Invalid : %s\n", yytext); }
  20. %%
  21.  
  22. int main() {
  23. printf("Enter input:\n");
  24. yylex();
  25. return 0;
  26. }
  27.  
  28. int yywrap() {
  29. return 1;
  30. }
Success #stdin #stdout #stderr 0.04s 6968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/oK89c9/prog:2:1: Syntax error: Operator expected
ERROR: /home/oK89c9/prog:30:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit