#include #define yputc(a) putc(a, yyout) #include "table.h" %% "\n" { int d = atoi(yytext + 3); yputc(0xfe); yputc(d); } "\n\n" { yputc(0xff); } "" { int d = strtoul(yytext + 5, NULL, 16); yputc(d); } "" { yputc(0xfb); yputc(0); } "" { yputc(0xfb); yputc(1); } "\n" { int d = atoi(yytext + 9); yputc(0xfb); yputc(9); yputc(d); } "" { int d = atoi(yytext + 7); yputc(0xfb); yputc(7); yputc(d); } "" { int d = atoi(yytext + 8); yputc(0xfb); yputc(d); } "" yputc(0xfa); "\n\n" yputc(0xf9); "\n" yputc(0xf8); "\n" yputc(0xf7); "" yputc(0x5c); "" yputc(0x5d); . { int i, trouve = 0; for (i = 0; i <= MAXCHAR; i++) { if (table[i] == *yytext) { trouve = 1; yputc(i); } } if (!trouve) { fprintf(stderr, "Caractère inconnu ligne %i: %s\n", yylineno, yytext); } } %% int yywrap(void) { exit(0); } int main(int argc, char ** argv) { if ((argc < 2) || (argc > 3)) { fprintf(stderr, "Usage: %s [input]\n", argv[0]); exit(-1); } if (!(yyout = fopen(argv[1], "wb"))) { fprintf(stderr, "Error: can't open file %s\n", argv[1]); exit(-1); } if (argc == 3) { if (!(yyin = fopen(argv[2], "rb"))) { fprintf(stderr, "Error: can't open file %s\n", argv[2]); exit(-1); } } fprintf(stderr, "Creating file %s\n", argv[1]); yylex(); return 0; }