xref: /minix3/external/bsd/flex/dist/examples/manual/replace.lex (revision 357f1050293be536ca8309aae20889945ce99fc1)
1*357f1050SThomas Veerman /*
2*357f1050SThomas Veerman  * replace.lex : A simple filter for renaming
3*357f1050SThomas Veerman  *               parts of flex of bison generated
4*357f1050SThomas Veerman  *               scanners or parsers.
5*357f1050SThomas Veerman  */
6*357f1050SThomas Veerman 
7*357f1050SThomas Veerman %{
8*357f1050SThomas Veerman #include <stdio.h>
9*357f1050SThomas Veerman 
10*357f1050SThomas Veerman char lower_replace[1024];
11*357f1050SThomas Veerman char upper_replace[1024];
12*357f1050SThomas Veerman 
13*357f1050SThomas Veerman %}
14*357f1050SThomas Veerman 
15*357f1050SThomas Veerman %%
16*357f1050SThomas Veerman 
17*357f1050SThomas Veerman "yy"   printf("%s",lower_replace);
18*357f1050SThomas Veerman "YY"   printf("%s",upper_replace);
19*357f1050SThomas Veerman ,      ECHO;
20*357f1050SThomas Veerman 
21*357f1050SThomas Veerman %%
22*357f1050SThomas Veerman 
23*357f1050SThomas Veerman int main(int argc, char *argv[])
24*357f1050SThomas Veerman {
25*357f1050SThomas Veerman    if(argc < 2){
26*357f1050SThomas Veerman      printf("Usage %s lower UPPER\n",argv[0]);
27*357f1050SThomas Veerman      exit(1);
28*357f1050SThomas Veerman    }
29*357f1050SThomas Veerman    strcpy(lower_replace,argv[1]);
30*357f1050SThomas Veerman    strcpy(upper_replace,argv[2]);
31*357f1050SThomas Veerman    yylex();
32*357f1050SThomas Veerman    return(0);
33*357f1050SThomas Veerman }
34