home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * 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);}
- ∞ LEXSRT C