fork download
  1. %option noyywrap
  2. %option nounput
  3.  
  4. %{
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. unsigned int cnt = 0;
  9. %}
  10.  
  11.  
  12. INT [0-9]+
  13. FLOAT ([0-9]*\.[0-9]+)|([0-9]+\.[0-9]*)
  14. SSTR \'[^\'\n]+\'
  15. DSTR \"[^\"\n]+\"
  16. VAR [A-Za-z_][A-Za-z0-9_]*
  17.  
  18. %%
  19.  
  20. {FLOAT} { printf("%s FLOAT\n", yytext); }
  21. {INT} { printf("%s INTEGER\n", yytext); }
  22. {SSTR} { printf("%s STRING\n", yytext); }
  23. {DSTR} { printf("%s STRING\n", yytext); }
  24. {VAR} { printf("%s VARIABLE\n", yytext); }
  25.  
  26. /* whitespace */
  27. [ \t]+ { /* ignore */ }
  28.  
  29. /* catch-all: consume one char to avoid infinite loops */
  30. .|\n { /* ignore invalid char/line */ }
  31.  
  32. %%
  33.  
  34. int main(void) {
  35. yylex();
  36. return 0;
  37. }
  38.  
  39. /*
  40. //3.in 2.in
  41. // SP [ \t]*
  42. // ^{SP}{FLOAT}{SP}\n?
  43. */
  44.  
Success #stdin #stdout #stderr 0.02s 6956KB
stdin
123
0aaa
4.5
"hello world"
.
a
"""
stdout
Standard output is empty
stderr
ERROR: /home/McGjbo/prog:5:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? % Execution Aborted
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit