diff options
Diffstat (limited to 'trigraph.l')
-rw-r--r-- | trigraph.l | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/trigraph.l b/trigraph.l deleted file mode 100644 index e9c4ca2..0000000 --- a/trigraph.l +++ /dev/null @@ -1,44 +0,0 @@ -%{ -#include <stdio.h> -#include "trigraph.h" - -#define yylex tglex - -static FILE *tgout; -static void replace_trigraph(int c); -static size_t tgline = 0; -static size_t tgchar = 0; -%} - -%% - -\?\?[=\/'\(\)!<>\-?] { replace_trigraph(yytext[2]); } -\n { tgline++; tgchar = 0; fputc(yytext[0], tgout); } -. { tgchar++; fputc(yytext[0], tgout); } - -%% - -static void replace_trigraph(int c) -{ - static int tg[] = { - ['='] = '#', - ['/'] = '\\', - ['\''] = '^', - ['('] = '[', - [')'] = ']', - ['!'] = '|', - ['<'] = '>', - ['-'] = '~', - ['?'] = '?', - }; - fprintf(stderr, "warning: replaced trigraph '??%c' with '%c' at __FILE__:%zd:%zd\n", - c, tg[c], /*__FILE__,*/ tgline, tgchar); - fputc(tg[c], tgout); -} - -int trigraph(FILE *in, FILE *out) -{ - yyin = in; - tgout = out; - return tglex(); -} |