%{ #include #include #include #include #include "dtd.h" #include "dtd_y.h" #define yytext dtdtext #define yyleng dtdleng #define yylval dtdlval extern int dtd_lineno; %} ws [ \t]+ id [_a-zA-Z1-9][_a-zA-Z1-9]* nl \n %% {ws} ; ^#.*{nl} {dtd_lineno++;}; --.*-- ; \ {return END;} \#PCDATA {return PCDATA;} EMPTY {return EMPTY;} \| {return OR;} , {return NEXT;} \( {return OPEN;} \) {return CLOSE;} \+ {return PLUS;} \* {return ASTARISK;} \? {return QUESTION;} o {return CHAR;} O {return CHAR;} - {return CHAR;} {id} { char *p, *s; if ((p = yylval.string = malloc(strlen(s = yytext)+1)) == NULL) { perror("malloc"); exit(1); } while (*s) *p++ = tolower(*s++); *p = '\0'; return ID;} {nl} {dtd_lineno++;} %%