summaryrefslogtreecommitdiff
path: root/PE/compil.lex
diff options
context:
space:
mode:
authorpixel <pixel>2003-12-25 15:14:02 +0000
committerpixel <pixel>2003-12-25 15:14:02 +0000
commit0177d50e3ae979872e5d8c60a7b4ca97b2ba9f5b (patch)
tree30f9433d06190aa03607000b9ab4593c08bed927 /PE/compil.lex
parentdc5101a46405b2d19892c3fde00268ef0344ddaf (diff)
Final push :-P
Diffstat (limited to 'PE/compil.lex')
-rw-r--r--PE/compil.lex52
1 files changed, 48 insertions, 4 deletions
diff --git a/PE/compil.lex b/PE/compil.lex
index cda7fa0..bc6614d 100644
--- a/PE/compil.lex
+++ b/PE/compil.lex
@@ -2,10 +2,31 @@
#define yputc(a) putc(a, yyout)
#include "table.h"
- int oldpt = -1;
+ int oldpt = -1, nbpts = -1;
+ int curptr = 0, p, full = 0;
+ void putptr(void);
%%
+"<NBPTS "[[:digit:]]+">\n" {
+ int i;
+ nbpts = atoi(yytext + 7);
+ fprintf(stderr, "nbpts = %i\n", nbpts);
+ unsigned short int z = 0;
+
+ fwrite(&nbpts, 2, 1, yyout);
+
+ for (i = 0; i < nbpts; i++) {
+ fwrite(&z, 2, 1, yyout);
+ }
+
+ curptr = 1;
+ p = ftell(yyout);
+ fseek(yyout, 2, SEEK_SET);
+ fwrite(&p, 2, 1, yyout);
+ fseek(yyout, p, SEEK_SET);
+}
+
"<PT"[[:digit:]]+">\n" {
int d = atoi(yytext + 3);
if (d != (oldpt + 1)) {
@@ -47,10 +68,11 @@
yputc(d);
}
-"\n<CLOSE>\n" yputc(0xff);
-"<CLOSE>\n" { yputc(0xf7); yputc(0xff); }
+"<CLOSE>\n" { yputc(0xff); putptr(); }
+"\n<CLOSE>\n" { yputc(0xff); putptr(); }
"<AYA>" yputc(0xfa);
-"\n<TCLOSE>\n" yputc(0xf9);
+"\n<TCLOSE>\n" { yputc(0xf9); putptr(); }
+"<EMPTYPTR>\n" { putptr(); }
"<PAUSE>\n" yputc(0xf8);
"\n" yputc(0xf7);
@@ -78,9 +100,31 @@
%%
int yywrap(void) {
+ if ((nbpts != -1) && (!full)) {
+ fprintf(stderr, "Pas assez de pointeurs\n");
+ }
exit(0);
}
+void putptr(void) {
+ if (nbpts == -1)
+ return;
+ if (curptr == nbpts) {
+ full = 1;
+ curptr++;
+ return;
+ }
+ if (curptr > nbpts) {
+ fprintf(stderr, "Trop de pointeurs ligne %i\n", yylineno);
+ return;
+ }
+ p = ftell(yyout);
+ fseek(yyout, 2 * curptr + 2, SEEK_SET);
+ fwrite(&p, 2, 1, yyout);
+ fseek(yyout, 0, SEEK_END);
+ curptr++;
+}
+
int main(int argc, char ** argv) {
if ((argc < 2) || (argc > 3)) {
fprintf(stderr, "Usage: %s <output> [input]\n", argv[0]);