mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 07:11:34 +00:00
Added tool that reads entity definitons into a file
This commit is contained in:
parent
75ec1fce7b
commit
e97c97d5d3
2 changed files with 78 additions and 0 deletions
17
code/tools/entityDefParser/README
Normal file
17
code/tools/entityDefParser/README
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Entity Definitions Parser
|
||||||
|
|
||||||
|
Required tools:
|
||||||
|
* flex
|
||||||
|
|
||||||
|
Building
|
||||||
|
flex quake.l
|
||||||
|
gcc lex.yy.c -o entityDefParser -lfl
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
./entityDefParser <code file> <output file>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
./entityDefParser game/g_mover.c hm_entities.def
|
||||||
|
./entityDefParser game/g_fx.c
|
||||||
|
Will produce a def file including all entity definitions from
|
||||||
|
g_mover.c and g_fx.c.
|
61
code/tools/entityDefParser/quaked.l
Normal file
61
code/tools/entityDefParser/quaked.l
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
%{
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
FILE *in, *out;
|
||||||
|
|
||||||
|
#define YY_DECL int yylex()
|
||||||
|
%}
|
||||||
|
|
||||||
|
%x C_QUAKED
|
||||||
|
%%
|
||||||
|
"/*QUAKED" { BEGIN(C_QUAKED); fprintf(out, "/*QUAKED"); }
|
||||||
|
<C_QUAKED>"*/" { BEGIN(INITIAL); fprintf(out, "*/\n\n"); }
|
||||||
|
<C_QUAKED>"\t" { fprintf(out, "\t"); }
|
||||||
|
<C_QUAKED>"\n" { fprintf(out, "\n"); }
|
||||||
|
<C_QUAKED>. { fprintf(out, "%s", yytext); }
|
||||||
|
[\n] ;
|
||||||
|
. ;
|
||||||
|
%%
|
||||||
|
|
||||||
|
main(int argc, char *argv[]) {
|
||||||
|
char *buf;
|
||||||
|
long len;
|
||||||
|
|
||||||
|
if(argc < 2) {
|
||||||
|
printf("Usage: %s <cfiles> <output file>\n", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
in = fopen(argv[1], "r");
|
||||||
|
if(!in) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
out = fopen(argv[2], "r");
|
||||||
|
if(out) {
|
||||||
|
fseek(out, 0, SEEK_END);
|
||||||
|
len = ftell(out);
|
||||||
|
fseek(out, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buf = (char *)malloc(len+1);
|
||||||
|
if(!buf) {
|
||||||
|
fclose(out);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fgets(buf, len, out);
|
||||||
|
fclose(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
out = fopen(argv[2], "a");
|
||||||
|
if(!out) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf != NULL) {
|
||||||
|
fprintf(out, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
yyin = in;
|
||||||
|
|
||||||
|
yylex();
|
||||||
|
}
|
Loading…
Reference in a new issue