fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6.  
  7. [0-9]+ { printf("Number: %s\n", yytext); }
  8.  
  9. #[^\n]* { printf("Comment: %s\n", yytext); }
  10.  
  11. \"[^\"]*\" { printf("Text String: %s\n", yytext); }
  12.  
  13. [A-Za-z_][A-Za-z0-9_]* { printf("Identifier/Command: %s\n", yytext); }
  14.  
  15. [ \t\n,]+ { /* ignore whitespace and commas */ }
  16.  
  17. . { printf("Unknown Token: %s\n", yytext); }
  18.  
  19. %%
  20.  
  21. int main(void)
  22. {
  23. printf("Enter your input sequence:\n");
  24. yylex();
  25. return 0;
  26. }
  27.  
  28.  
Success #stdin #stdout #stderr 0.03s 6868KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Ij3Los/prog:2:1: Syntax error: Operator expected
ERROR: /home/Ij3Los/prog:27:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit