From 44adf768555ecd211f90cbf4d87b44ba42044d86 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 5 Sep 2003 23:50:16 +0000 Subject: Continuing toying --- PE/compil.lex | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 PE/compil.lex (limited to 'PE/compil.lex') diff --git a/PE/compil.lex b/PE/compil.lex new file mode 100644 index 0000000..e59c6b1 --- /dev/null +++ b/PE/compil.lex @@ -0,0 +1,93 @@ + #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: %s\n", yytext); + } +} + +%% + +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(); + exit(0); +} -- cgit v1.2.3