summaryrefslogtreecommitdiff
path: root/examples/manual/replace.lex
blob: c5c8d87713de05a9ee2473c7b791bedc87874569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * replace.lex : A simple filter for renaming
 *               parts of flex of bison generated
 *               scanners or parsers.
 */

%{
#include <stdio.h>

char lower_replace[1024];
char upper_replace[1024];

%}

%%

"yy"   printf("%s",lower_replace); 
"YY"   printf("%s",upper_replace);
,      ECHO;

%%

int main(int argc, char *argv[])
{
   if(argc < 2){
     printf("Usage %s lower UPPER\n",argv[0]);
     exit(1);
   }
   strcpy(lower_replace,argv[1]);
   strcpy(upper_replace,argv[2]);
   yylex();
   return(0);
}