summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compil.lex190
1 files changed, 95 insertions, 95 deletions
diff --git a/compil.lex b/compil.lex
index ad24a2c..504eaaf 100644
--- a/compil.lex
+++ b/compil.lex
@@ -23,181 +23,181 @@
%%
<INITIAL>"<roomscripts>" {
- fprintf(yyout, "rooms_txts = {\n");
- BEGIN(I);
+ fprintf(yyout, "rooms_txts = {\n");
+ BEGIN(I);
}
-<INITIAL>.* {
- fprintf(stderr, "Invalid file, must begin with <roomscripts>\n");
- errstate = 1;
+<INITIAL>.* {
+ fprintf(stderr, "Invalid file, must begin with <roomscripts>\n");
+ errstate = 1;
}
-<I>"\n\n<ptr n=\""[[:digit:]]+"\" room=\""[^\"]*"\"/>\n" {
- int d = atoi(yytext + 10);
- if (got_ptr) {
- fprintf(yyout, "\x5d\x5d },\n");
- }
- fprintf(yyout, " [%i] = { \x5b\x5b", d);
- got_ptr = 1;
+<I>"\n\n<ptr n=\""[[:digit:]]+"\" room=\""[^\"]*"\"/>\n" {
+ int d = atoi(yytext + 10);
+ if (got_ptr) {
+ fprintf(yyout, "\x5d\x5d },\n");
+ }
+ fprintf(yyout, " [%i] = { \x5b\x5b", d);
+ got_ptr = 1;
}
-<I>"\n<new/>\n" {
- putcode(1);
+<I>"\n<new/>\n" {
+ putcode(1);
}
-<I>"<rspd/>" {
- putcode1(3, 255);
+<I>"<rspd/>" {
+ putcode1(3, 255);
}
-<I>"<st spd=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 9);
- putcode1(3, d);
+<I>"<st spd=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 9);
+ putcode1(3, d);
}
-<I>"<st clr=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 9);
- putcode1(4, d);
+<I>"<st clr=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 9);
+ putcode1(4, d);
}
-<I>"<start/>" {
- putcode(5);
+<I>"<start/>" {
+ putcode(5);
}
-<I>"<rrep/>" {
- putcode1(7, 1);
+<I>"<rrep/>" {
+ putcode1(7, 1);
}
-<I>"<st rep=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 9);
- putcode1(7, d);
+<I>"<st rep=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 9);
+ putcode1(7, d);
}
-<I>"<rsiz/>" {
- putcode1(8, 1);
+<I>"<rsiz/>" {
+ putcode1(8, 1);
}
-<I>"<st siz=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 9);
- putcode1(8, d);
+<I>"<st siz=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 9);
+ putcode1(8, d);
}
-<I>"<dport/>" {
- putcode2(19, 255, 255);
+<I>"<dport/>" {
+ putcode2(19, 255, 255);
}
-<I>"<port a1=\""[[:digit:]]+"\" " {
- arg1 = atoi(yytext + 10);
- BEGIN(P);
+<I>"<port a1=\""[[:digit:]]+"\" " {
+ arg1 = atoi(yytext + 10);
+ BEGIN(P);
}
-<P>"a2=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 4);
- putcode2(19, arg1, d);
- BEGIN(I);
+<P>"a2=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 4);
+ putcode2(19, arg1, d);
+ BEGIN(I);
}
-<I>"<var n=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 8);
- putcode1(14, d);
+<I>"<var n=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 8);
+ putcode1(14, d);
}
-<I>"<uk c=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 7);
- putcode(d);
+<I>"<uk c=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 7);
+ putcode(d);
}
-<I>"<u1 c=\""[[:digit:]]+"\" " {
- cmd = atoi(yytext + 7);
- BEGIN(U1);
+<I>"<u1 c=\""[[:digit:]]+"\" " {
+ cmd = atoi(yytext + 7);
+ BEGIN(U1);
}
-<U1>"a1=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 4);
- putcode1(cmd, d);
- BEGIN(I);
+<U1>"a1=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 4);
+ putcode1(cmd, d);
+ BEGIN(I);
}
-<I>"<u2 c=\""[[:digit:]]+"\" " {
- cmd = atoi(yytext + 7);
- BEGIN(U21);
+<I>"<u2 c=\""[[:digit:]]+"\" " {
+ cmd = atoi(yytext + 7);
+ BEGIN(U21);
}
-<U21>"a1=\""[[:digit:]]+"\" " {
- arg1 = atoi(yytext + 4);
- BEGIN(U22);
+<U21>"a1=\""[[:digit:]]+"\" " {
+ arg1 = atoi(yytext + 4);
+ BEGIN(U22);
}
-<U22>"a2=\""[[:digit:]]+"\"/>" {
- int d = atoi(yytext + 4);
- putcode2(cmd, arg1, d);
- BEGIN(I);
+<U22>"a2=\""[[:digit:]]+"\"/>" {
+ int d = atoi(yytext + 4);
+ putcode2(cmd, arg1, d);
+ BEGIN(I);
}
-<I>"\n" {
- putcode(0);
+<I>"\n" {
+ putcode(0);
}
-<I>"</roomscripts>\n" {
- fprintf(yyout, "\x5d\x5d}\n}\n");
- BEGIN(E);
+<I>"</roomscripts>\n" {
+ fprintf(yyout, "\x5d\x5d}\n}\n");
+ BEGIN(E);
}
-<I>"abcdef<"[^\>\n]*"/>" {
- yytext[strlen(yytext) - 2] = 0;
- fprintf(stderr, "Error: Invalid command: '%s'\n", yytext + 1);
- errstate = 1;
+<I>"abcdef<"[^\>\n]*"/>" {
+ yytext[strlen(yytext) - 2] = 0;
+ fprintf(stderr, "Error: Invalid command: '%s'\n", yytext + 1);
+ errstate = 1;
}
-<I>. {
- fputc(*yytext, yyout);
+<I>. {
+ 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 <output> [input]\n", argv[0]);
- exit(-1);
+ 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);
+ 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);
}