fork download
  1. %option noyywrap
  2. %option nounput
  3.  
  4. %{
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. unsigned int cnt = 0;
  10. %}
  11. INT [0-9]+
  12. FLOAT ([0-9]*\.[0-9]+)|([0-9]+\.[0-9]*)
  13. SSTR '[^'\n]+'
  14. DSTR "[^\"\n]+"
  15. VAR [A-Za-z_][A-Za-z0-9_]*
  16. %%
  17. {INT} { printf("%s INRERGER\n", yytext); }
  18. {FLOAT} { printf("%s FLOAT\n", yytext); }
  19. {SSTR} { printf("%s STRING\n", yytext); }
  20. {DSTR} { printf("%s STRING\n", yytext); }
  21. {VAR} { printf("%s VARIABLE\n", yytext); }
  22. ^.*\n? { /* ignore invalid line */ }
  23. [ \t]+ ;
  24.  
  25. %%
  26. int main(void) {
  27. yylex();
  28. return 0;
  29. }
  30.  
  31.  
  32. //3.in 2.in
  33. // SP [ \t]*
  34. // ^{SP}{FLOAT}{SP}\n?
Success #stdin #stdout #stderr 0.04s 7008KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/KHGs0m/prog:5:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit