fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6.  
  7. int { printf("Keyword: int\n"); } float { printf("Keyword: float\n"); } if { printf("Keyword: if\n"); }
  8. [0-9]+ { printf("Number: %s\n", yytext); }
  9. [a-zA-Z]+ { printf("Identifier: %s\n", yytext); }
  10. . { /* Ignore other characters */ }
  11.  
  12. %%
  13.  
  14. int main() {
  15. yylex(); return 0;
  16. }
  17.  
  18.  
Success #stdin #stdout #stderr 0.03s 6872KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ljvQWX/prog:2:1: Syntax error: Operator expected
ERROR: /home/ljvQWX/prog:17:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit