fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. letter [a-zA-Z]
  6. digit [0-9]
  7. letdigit {letter}|{digit}
  8.  
  9. %%
  10.  
  11. {letter} { printf("Letter: %c\n", yytext[0]); }
  12. {digit} { printf("Digit: %c\n", yytext[0]); }
  13. {letdigit}+ { printf("ID: %s\n", yytext); }
  14. \n { printf("New line character\n"); }
  15. [ ] { printf("space\n"); }
  16. \' { printf("single quote\n"); }
  17. . { /* ignore other characters */ }
  18.  
  19. %%
  20.  
  21. int main() {
  22. yylex();
  23. return 0;
  24. }
Success #stdin #stdout #stderr 0.02s 6884KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/GamR4l/prog:2:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit