fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. /* Define patterns */
  6. letter [a-zA-Z]
  7. digit [0-9]
  8. id {letter}({letter}|{digit})*
  9. float {digit}+"."{digit}*
  10.  
  11. %%
  12.  
  13. {id} { printf("Valid Identifier: %s\n", yytext); }
  14. {float} { printf("Valid Floating Point Number: %s\n", yytext); }
  15. . { printf("Invalid Token: %s\n", yytext); }
  16.  
  17. %%
  18.  
  19. int main(void) {
  20. yylex(); // Start lexical analysis
  21. return 0;
  22. }
  23.  
  24. int yywrap() {
  25. return 1;
  26. }
  27.  
Success #stdin #stdout #stderr 0.02s 6972KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/VYSQRM/prog:2:1: Syntax error: Operator expected
ERROR: /home/VYSQRM/prog:26:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit