fork download
  1. #@title Writing Lex program
  2. %%writefile program.l
  3. %{
  4. #include <stdio.h>
  5. %}
  6. %%
  7. [ \t] ;
  8. [0-9]+\.[0-9]+ {printf("\nFound a floating-point number:");
  9. printf("%s",yytext);}
  10. [0-9]+ {printf("\nFound an integer:"); printf("%s",yytext); }
  11. [a-zA-Z0-9]+ {printf("\nFound a string: ");printf("%s",yytext);}
  12. %%
  13. main() {
  14. // lex through the input:
  15. yylex();
  16. }
Success #stdin #stdout #stderr 0.04s 6968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/thmPP1/prog:16:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit