home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
c
/
lex.arc
/
BTOB.LXI
< prev
next >
Wrap
Text File
|
1980-01-01
|
1KB
|
53 lines
/*
* btob -- convert old b operators to new b form
*/
%{
struct maptab {
char *old;
char *new;
} maptab[] {
"=+", "+=",
"=-", "-=",
"=*", "*=",
"=%", "%=",
"=&", "&=",
"=|", "|=",
"=<<", "<<=",
"=>>", ">>=",
"=/", "/=",
"=^", "^=",
0,
};
struct maptab *mp;
char tbuf[10];
char *token();
main()
{
while (yylex())
;
}
%}
%%
"=" (<< | >> | "*" | + | - | "/" | "%" | "&" | "|" | "^") {
gettoken(tbuf, sizeof tbuf);
for (mp = maptab; mp->old; mp++)
if (equal(tbuf, mp->old)) {
printf("%s", mp->new);
break;
}
if (mp->old==0)
fprintf(stderr, "error\n");
return(1);
}
[<=>!]"=" {
relat:
gettoken(tbuf, sizeof tbuf);
printf(tbuf);
}
"="[<>] {goto relat;}
"=" / (++ | --) {printf("="); return(1);}
[\0-\377] {putchar(*token(NULL)); return(1);}