fork download
  1. /* Lex program to check whether input is digit or not. */
  2. %{
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. %}
  6. /* Rule Section */
  7. %%
  8. ^[0-9]* printf("digit");
  9. ^[^0-9]|[0-9]*[a-zA-Z] printf("not a digit");
  10. . ;
  11. %%
  12. int main()
  13. {
  14. // The function that starts the analysis
  15. yylex();
  16. return 0;
  17. }
  18.  
Success #stdin #stdout #stderr 0.03s 6992KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/w5VLFW/prog:3:1: Syntax error: Operator expected
ERROR: /home/w5VLFW/prog:17:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit