flex/examples/manual/replace.lex
Eric S. Raymond 8d0162b80a Update all the examples to use the new API elements.
Add a fully reentrant example.  And update to TODO file.
2020-10-12 21:07:14 -04:00

34 lines
533 B
Plaintext

/*
* 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);
, yyecho();
%%
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);
}