From 74ffe8d105c70e0e205cccba360f832d83b4abda Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 28 Oct 2012 22:32:50 -0700 Subject: Removing tabs. --- compil.lex | 190 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index ad24a2c..504eaaf 100644 --- a/compil.lex +++ b/compil.lex @@ -23,181 +23,181 @@ %% "" { - fprintf(yyout, "rooms_txts = {\n"); - BEGIN(I); + fprintf(yyout, "rooms_txts = {\n"); + BEGIN(I); } -.* { - fprintf(stderr, "Invalid file, must begin with \n"); - errstate = 1; +.* { + fprintf(stderr, "Invalid file, must begin with \n"); + errstate = 1; } -"\n\n\n" { - int d = atoi(yytext + 10); - if (got_ptr) { - fprintf(yyout, "\x5d\x5d },\n"); - } - fprintf(yyout, " [%i] = { \x5b\x5b", d); - got_ptr = 1; +"\n\n\n" { + int d = atoi(yytext + 10); + if (got_ptr) { + fprintf(yyout, "\x5d\x5d },\n"); + } + fprintf(yyout, " [%i] = { \x5b\x5b", d); + got_ptr = 1; } -"\n\n" { - putcode(1); +"\n\n" { + putcode(1); } -"" { - putcode1(3, 255); +"" { + putcode1(3, 255); } -"" { - int d = atoi(yytext + 9); - putcode1(3, d); +"" { + int d = atoi(yytext + 9); + putcode1(3, d); } -"" { - int d = atoi(yytext + 9); - putcode1(4, d); +"" { + int d = atoi(yytext + 9); + putcode1(4, d); } -"" { - putcode(5); +"" { + putcode(5); } -"" { - putcode1(7, 1); +"" { + putcode1(7, 1); } -"" { - int d = atoi(yytext + 9); - putcode1(7, d); +"" { + int d = atoi(yytext + 9); + putcode1(7, d); } -"" { - putcode1(8, 1); +"" { + putcode1(8, 1); } -"" { - int d = atoi(yytext + 9); - putcode1(8, d); +"" { + int d = atoi(yytext + 9); + putcode1(8, d); } -"" { - putcode2(19, 255, 255); +"" { + putcode2(19, 255, 255); } -"""a2=\""[[:digit:]]+"\"/>" { - int d = atoi(yytext + 4); - putcode2(19, arg1, d); - BEGIN(I); +

"a2=\""[[:digit:]]+"\"/>" { + int d = atoi(yytext + 4); + putcode2(19, arg1, d); + BEGIN(I); } -"" { - int d = atoi(yytext + 8); - putcode1(14, d); +"" { + int d = atoi(yytext + 8); + putcode1(14, d); } -"" { - int d = atoi(yytext + 7); - putcode(d); +"" { + int d = atoi(yytext + 7); + putcode(d); } -"""a1=\""[[:digit:]]+"\"/>" { - int d = atoi(yytext + 4); - putcode1(cmd, d); - BEGIN(I); +"a1=\""[[:digit:]]+"\"/>" { + int d = atoi(yytext + 4); + putcode1(cmd, d); + BEGIN(I); } -"""a1=\""[[:digit:]]+"\" " { - arg1 = atoi(yytext + 4); - BEGIN(U22); +"a1=\""[[:digit:]]+"\" " { + arg1 = atoi(yytext + 4); + BEGIN(U22); } -"a2=\""[[:digit:]]+"\"/>" { - int d = atoi(yytext + 4); - putcode2(cmd, arg1, d); - BEGIN(I); +"a2=\""[[:digit:]]+"\"/>" { + int d = atoi(yytext + 4); + putcode2(cmd, arg1, d); + BEGIN(I); } -"\n" { - putcode(0); +"\n" { + putcode(0); } -"\n" { - fprintf(yyout, "\x5d\x5d}\n}\n"); - BEGIN(E); +"\n" { + fprintf(yyout, "\x5d\x5d}\n}\n"); + BEGIN(E); } -"abcdef<"[^\>\n]*"/>" { - yytext[strlen(yytext) - 2] = 0; - fprintf(stderr, "Error: Invalid command: '%s'\n", yytext + 1); - errstate = 1; +"abcdef<"[^\>\n]*"/>" { + yytext[strlen(yytext) - 2] = 0; + fprintf(stderr, "Error: Invalid command: '%s'\n", yytext + 1); + errstate = 1; } -. { - fputc(*yytext, yyout); +. { + fputc(*yytext, yyout); } -. { - fprintf(stderr, "Hu uh, something's wrong...\n"); +. { + fprintf(stderr, "Hu uh, something's wrong...\n"); } %% -int yywrap(void) { +int yywrap(void) { exit(errstate ? -1 : 0); } -int main(int argc, char ** argv) { +int main(int argc, char ** argv) { if ((argc < 2) || (argc > 3)) { - fprintf(stderr, "Usage: %s [input]\n", argv[0]); - exit(-1); + 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); + 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); - } + 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(errstate ? -1 : 0); } -void unputs(char * s) { +void unputs(char * s) { int l = strlen(s), i; - + for (i = l - 1; i >= 0; i--) { - unput(s[i]); + unput(s[i]); } } -void putcode(int code) { +void putcode(int code) { fprintf(yyout, "\x5d\x5d, { %i }, \x5b\x5b", code); } -void putcode1(int code, int arg) { +void putcode1(int code, int arg) { fprintf(yyout, "\x5d\x5d, { %i, %i }, \x5b\x5b", code, arg); } -void putcode2(int code, int arg1, int arg2) { +void putcode2(int code, int arg1, int arg2) { fprintf(yyout, "\x5d\x5d, { %i, %i, %i }, \x5b\x5b", code, arg1, arg2); } -- cgit v1.2.3 From f37bccb877d23a3094e7b98f2742ed66fcdb00b6 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 28 Oct 2012 22:52:35 -0700 Subject: Adding unknown tag support to the script compiler. --- compil.lex | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index 504eaaf..1bac4f2 100644 --- a/compil.lex +++ b/compil.lex @@ -20,6 +20,13 @@ int errstate = 0; int got_ptr = 0; + const int max_tagsize = 64; + + char unknown_tag[65]; + char * unknown_tag_ptr; + + int in_unknown_tag = 0; + %% "" { @@ -149,6 +156,19 @@ } . { + if (*yytext == '<') { + in_unknown_tag = 1; + unknown_tag_ptr = unknown_tag; + } else if (*yytext == '>') { + *unknown_tag_ptr = 0; + fprintf(stderr, "Got an unknown tag: %s\n", unknown_tag); + in_unknown_tag = 0; + } else if (in_unknown_tag) { + *unknown_tag_ptr++ = *yytext; + if ((unknown_tag_ptr - unknown_tag) == max_tagsize) { + in_unknown_tag = 0; + } + } fputc(*yytext, yyout); } -- cgit v1.2.3 From 0fbf22d5fe5b7e07377ee9f133ab812e1a1fbdac Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 28 Oct 2012 23:44:09 -0700 Subject: Adding the new tags in the compilation code. --- compil.lex | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index 1bac4f2..b8cf4f0 100644 --- a/compil.lex +++ b/compil.lex @@ -3,6 +3,8 @@ %s I /* In port block */ %s P + /* In delay block */ +%s D /* In unknown 1 block */ %s U1 /* In unknown 2 block, arg1 */ @@ -97,6 +99,31 @@ BEGIN(P); } +"" { + putcode(18); + } + +""u=\""[[:digit:]]+"\"/>" { + int d = atoi(yytext + 3); + putcode2(17, d, arg1); + BEGIN(I); + } + +"" { + int t = atoi(yytext + 11); + putcode2(17, t, 0); + } + +"" { + int t = atoi(yytext + 11); + putcode2(17, t, 1); + } +

"a2=\""[[:digit:]]+"\"/>" { int d = atoi(yytext + 4); putcode2(19, arg1, d); -- cgit v1.2.3 From 6c1e07f91277d4ec5e2677707d96d1fd2641753c Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 28 Oct 2012 23:53:12 -0700 Subject: Removing useless check. --- compil.lex | 6 ------ 1 file changed, 6 deletions(-) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index b8cf4f0..960cab9 100644 --- a/compil.lex +++ b/compil.lex @@ -176,12 +176,6 @@ BEGIN(E); } -"abcdef<"[^\>\n]*"/>" { - yytext[strlen(yytext) - 2] = 0; - fprintf(stderr, "Error: Invalid command: '%s'\n", yytext + 1); - errstate = 1; - } - . { if (*yytext == '<') { in_unknown_tag = 1; -- cgit v1.2.3 From 9eede342a1046ce8e26c87495737585d042add19 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 29 Oct 2012 00:55:15 -0700 Subject: First step in getting the windows re-inserted properly: parsing them and transforming them into Lua code. --- compil.lex | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 6 deletions(-) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index 960cab9..d75f157 100644 --- a/compil.lex +++ b/compil.lex @@ -1,4 +1,12 @@ #include + /* Waiting for Window */ +%s WW + /* Waiting for Window Y */ +%s WWY + /* Waiting for Window W */ +%s WWW + /* Waiting for Window H */ +%s WWH /* In text block */ %s I /* In port block */ @@ -21,14 +29,21 @@ int arg1 = 0; int errstate = 0; int got_ptr = 0; + int current_ptr = 0; const int max_tagsize = 64; char unknown_tag[65]; - char * unknown_tag_ptr; + char * unknown_tag_ptr = unknown_tag; int in_unknown_tag = 0; + struct window { + int t, x, y, w, h; + }; + + struct window windows[8192]; + %% "" { @@ -42,12 +57,54 @@ } "\n\n\n" { - int d = atoi(yytext + 10); + current_ptr = atoi(yytext + 10); if (got_ptr) { fprintf(yyout, "\x5d\x5d },\n"); } - fprintf(yyout, " [%i] = { \x5b\x5b", d); + fprintf(yyout, " [%i] = { \x5b\x5b", current_ptr); got_ptr = 1; + BEGIN(WW); + } + +"\n" { + BEGIN(I); + } + +"\n" { + windows[current_ptr].t = 3; + BEGIN(I); + } + +"""y=\""[[:digit:]]+"\" " { + int d = atoi(yytext + 3); + windows[current_ptr].y = d; + BEGIN(WWW); + } + +"width=\""[[:digit:]]+"\" " { + int d = atoi(yytext + 7); + windows[current_ptr].w = d; + BEGIN(WWH); + } + +"height=\""[[:digit:]]+"\"/>" { + int d = atoi(yytext + 8); + windows[current_ptr].h = d; + BEGIN(I); } "\n\n" { @@ -172,7 +229,22 @@ } "\n" { - fprintf(yyout, "\x5d\x5d}\n}\n"); + int i; + fprintf(yyout, "\x5d\x5d}\n}\n\nwindows_data = {\n"); + for (i = 0; i < 8192; i++) { + switch (windows[i].t) { + case 1: + fprintf(yyout, " [%i] = { x = \"%i\", y = \"%i\", width = \"%i\", height = \"%i\" },\n", i, windows[i].x, windows[i].y, windows[i].w, windows[i].h); + break; + case 2: + fprintf(yyout, " [%i] = { x = \"var\", y = \"%i\", width = \"%i\", height = \"%i\" },\n", i, windows[i].y, windows[i].w, windows[i].h); + break; + case 3: + fprintf(yyout, " [%i] = { wtype = \"fixed\" },\n", current_ptr); + break; + } + } + fprintf(yyout, "}\n"); BEGIN(E); } @@ -180,7 +252,7 @@ if (*yytext == '<') { in_unknown_tag = 1; unknown_tag_ptr = unknown_tag; - } else if (*yytext == '>') { + } else if ((*yytext == '>') && in_unknown_tag) { *unknown_tag_ptr = 0; fprintf(stderr, "Got an unknown tag: %s\n", unknown_tag); in_unknown_tag = 0; @@ -194,7 +266,7 @@ } . { - fprintf(stderr, "Hu uh, something's wrong...\n"); + fprintf(stderr, "Hu uh, something's wrong... unexpected %s\n", yytext); } %% @@ -218,6 +290,7 @@ int main(int argc, char ** argv) { exit(-1); } } + memset(windows, 0, sizeof(windows)); fprintf(stderr, "Creating file %s\n", argv[1]); yylex(); exit(errstate ? -1 : 0); -- cgit v1.2.3 From ad728683a0f8896508bcf24dadf9161b158573af Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 29 Oct 2012 01:00:19 -0700 Subject: Oops. --- compil.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compil.lex') diff --git a/compil.lex b/compil.lex index d75f157..36db5c5 100644 --- a/compil.lex +++ b/compil.lex @@ -240,7 +240,7 @@ fprintf(yyout, " [%i] = { x = \"var\", y = \"%i\", width = \"%i\", height = \"%i\" },\n", i, windows[i].y, windows[i].w, windows[i].h); break; case 3: - fprintf(yyout, " [%i] = { wtype = \"fixed\" },\n", current_ptr); + fprintf(yyout, " [%i] = { wtype = \"fixed\" },\n", i); break; } } -- cgit v1.2.3