summaryrefslogtreecommitdiff
path: root/PE/compil.lex
diff options
context:
space:
mode:
authorpixel <pixel>2003-09-05 23:50:16 +0000
committerpixel <pixel>2003-09-05 23:50:16 +0000
commit44adf768555ecd211f90cbf4d87b44ba42044d86 (patch)
tree662018d76d3f2f19ed58ea8e94c54445fc2a47e4 /PE/compil.lex
parent7ff77f49e9577ff5b63d7f2e2ce7651257bf1d63 (diff)
Continuing toying
Diffstat (limited to 'PE/compil.lex')
-rw-r--r--PE/compil.lex93
1 files changed, 93 insertions, 0 deletions
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"
+
+%%
+
+"<PT"[[:digit:]]+">\n" {
+ int d = atoi(yytext + 3);
+ yputc(0xfe);
+ yputc(d);
+}
+
+"\n<CLOSE>\n" {
+ yputc(0xff);
+}
+
+"<UNK "[[:xdigit:]]{2}">" {
+ int d = strtoul(yytext + 5, NULL, 16);
+ yputc(d);
+}
+
+"<TAG0>" {
+ yputc(0xfb);
+ yputc(0);
+}
+
+"<TAG1>" {
+ yputc(0xfb);
+ yputc(1);
+}
+
+"<CHOICES "[[:digit:]]+">\n" {
+ int d = atoi(yytext + 9);
+ yputc(0xfb);
+ yputc(9);
+ yputc(d);
+}
+
+"<TIMER "[[:digit:]]+">" {
+ int d = atoi(yytext + 7);
+ yputc(0xfb);
+ yputc(7);
+ yputc(d);
+}
+
+"<UNKCMD "[[:digit:]]+">" {
+ int d = atoi(yytext + 8);
+ yputc(0xfb);
+ yputc(d);
+}
+
+"<AYA>" yputc(0xfa);
+"\n<TCLOSE>\n" yputc(0xf9);
+"<PAUSE>\n" yputc(0xf8);
+"\n" yputc(0xf7);
+
+"<ae>" yputc(0x5c);
+"<oe>" 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 <output> [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);
+}