fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. %}
  5.  
  6. DIGIT [0-9]
  7. OCTAL [0-7]+
  8. BINARY [01]+
  9. HEX [0-9A-Fa-f]+
  10. FLOAT [-]?{DIGIT}+\.{DIGIT}*
  11. EXP [-]?{DIGIT}*\.?{DIGIT}+([eE][-]?{DIGIT}+)
  12.  
  13. %%
  14. ^{BINARY}$ { printf("%s is a Binary\n", yytext); }
  15. ^{OCTAL}$ { printf("%s is an Octal\n", yytext); }
  16. ^{HEX}$ { printf("%s is a Hexadecimal\n", yytext); }
  17. ^{FLOAT}$ { printf("%s is a Float\n", yytext); }
  18. ^{EXP}$ { printf("%s is an Exponent\n", yytext); }
  19. . { /* Ignore other characters */ }
  20.  
  21. %%
  22.  
  23. int main() {
  24. yylex();
  25. return 0;
  26. }
  27.  
  28. int yywrap() {
  29. return 1;
  30. }
Success #stdin #stdout #stderr 0.03s 6860KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/TqSewF/prog:2:1: Syntax error: Operator expected
ERROR: /home/TqSewF/prog:30:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit