%{ /* * This lexer accepts input from another file instead of stdin * This is accomplished reassigning yyin = file */ %} %% [\t ]+ /*recognize and ignore any number of tabs or white spaces*/ ; [a-zA-Z ] { printf("%s: This is a letter\n", yytext); } .|\n { ECHO; /* normal default anyway */ } %% main(argc,argv) int argc; char **argv; { if (argc > 1) { FILE *file; file = fopen(argv[1], "r"); if (!file) { fprintf(stderr,"could not open %s\n",argv[1]); exit(1); } yyin = file; } yylex(); return 0; }