mirror of
https://github.com/UberGames/rpgxEF.git
synced 2025-02-15 16:41:16 +00:00
Minor changes to the lua function definitions lexer
This commit is contained in:
parent
1953cfaa25
commit
1abb89ff21
3 changed files with 158 additions and 25 deletions
82
code/tools/luaDefParser/export_lyx.c
Normal file
82
code/tools/luaDefParser/export_lyx.c
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#include "export_lyx.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
function_p create_function(void) {
|
||||||
|
function_p n = (function_p)malloc(sizeof(function_s));
|
||||||
|
|
||||||
|
if(n == NULL) return NULL;
|
||||||
|
|
||||||
|
n->desc = create_list();
|
||||||
|
if(n->desc == NULL) {
|
||||||
|
free(n);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
n->params = create_list();
|
||||||
|
if(n->params == NULL) {
|
||||||
|
destroy_list(n->desc);
|
||||||
|
free(n);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_function(function_p f) {
|
||||||
|
if(f != NULL) {
|
||||||
|
if(f->desc != NULL) {
|
||||||
|
destroy_list(f->desc);
|
||||||
|
}
|
||||||
|
if(f->params != NULL) {
|
||||||
|
destroy_list(f->params);
|
||||||
|
}
|
||||||
|
free(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
desc_p create_desc(void) {
|
||||||
|
desc_p n = (desc_p)malloc(sizeof(desc_s));
|
||||||
|
|
||||||
|
if(n == NULL) return NULL;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_desc(desc_p d) {
|
||||||
|
if(d != NULL) {
|
||||||
|
if(d->text != NULL) {
|
||||||
|
free(d->text);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
param_p create_param(void) {
|
||||||
|
param_p n = (param_p)malloc(sizeof(param_s));
|
||||||
|
|
||||||
|
if(n == NULL) return NULL;
|
||||||
|
|
||||||
|
n->desc = create_list();
|
||||||
|
if(n->desc == NULL) {
|
||||||
|
free(n);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_param(param_p p) {
|
||||||
|
if (p != NULL) {
|
||||||
|
if(p->name != NULL) {
|
||||||
|
free(p->name);
|
||||||
|
}
|
||||||
|
if(p->desc != NULL) {
|
||||||
|
destroy_list(p->desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
}
|
51
code/tools/luaDefParser/export_lyx.h
Normal file
51
code/tools/luaDefParser/export_lyx.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef EXPORT_LYX_H_
|
||||||
|
#define EXPORT_LYX_H_
|
||||||
|
|
||||||
|
#include "../../game/list.h"
|
||||||
|
|
||||||
|
typedef struct function_s* function_p;
|
||||||
|
struct function_s {
|
||||||
|
char* name;
|
||||||
|
list_p desc;
|
||||||
|
list_p params;
|
||||||
|
} function_s;
|
||||||
|
function_p create_function(void);
|
||||||
|
void destroy_function(function_p f);
|
||||||
|
|
||||||
|
typedef struct desc_s* desc_p;
|
||||||
|
struct desc_s {
|
||||||
|
char* text;
|
||||||
|
} desc_s;
|
||||||
|
desc_p create_desc(void);
|
||||||
|
void destroy_desc(desc_p d);
|
||||||
|
|
||||||
|
typedef enum { FLOAT, ENTITY, VECTOR } pType;
|
||||||
|
|
||||||
|
typedef struct param_s* param_p;
|
||||||
|
struct param_s {
|
||||||
|
pType type;
|
||||||
|
char* name;
|
||||||
|
list_p desc;
|
||||||
|
} param_s;
|
||||||
|
param_p create_param(void);
|
||||||
|
void destroy_param(param_p p);
|
||||||
|
|
||||||
|
void write_function(function_p f);
|
||||||
|
void write_desc(list_p d);
|
||||||
|
void write_param(param_p p);
|
||||||
|
|
||||||
|
#define BEGIN_SECTION "\\begin_layout Section"
|
||||||
|
#define BEGIN_SUBSECTION "\\begin_layout Subsection"
|
||||||
|
#define BEGIN_STANDART "\\begin_layout Standart"
|
||||||
|
#define END_LAYOUT "\\ent_layout
|
||||||
|
|
||||||
|
#define BEGIN_TABULAR "\
|
||||||
|
\\begin_layout Standard\
|
||||||
|
\\begin_inset Tabular\
|
||||||
|
<lyxtabular version=\"3\" rows=\"2\" columns=\"3\">\
|
||||||
|
<features tabularvalignment=\"middle\">\
|
||||||
|
<column alignment=\"center\" valignment=\"top\" width=\"0\">\
|
||||||
|
<column alignment=\"center\" valignment=\"top\" width=\"0\">\
|
||||||
|
<column alignment=\"center\" valignment=\"top\" width=\"0\">"
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,46 +19,46 @@ FUNCTEXT [a-zA-z0-9.(), \t]+
|
||||||
STRING [a-zA-z0-9.(), \t\n!?<>/\\\[\]\{\}]+
|
STRING [a-zA-z0-9.(), \t\n!?<>/\\\[\]\{\}]+
|
||||||
VAR [a-zA-Z0-9]+
|
VAR [a-zA-Z0-9]+
|
||||||
%%
|
%%
|
||||||
"/*" { BEGIN(C_COMMENT); puts("Found a comment"); }
|
"/*" { BEGIN(C_COMMENT); puts("Found a comment"); }
|
||||||
<C_COMMENT>"*/" { BEGIN(INITIAL); puts("End of comment"); }
|
<C_COMMENT>"*/" { BEGIN(INITIAL); puts("End of comment"); }
|
||||||
<C_COMMENT>[ \t\n*] ;
|
<C_COMMENT>[ \t\n*] ;
|
||||||
<C_COMMENT>"luamodule" { BEGIN(C_MODULE); puts("Found a luamodule"); }
|
<C_COMMENT>"luamodule" { BEGIN(C_MODULE); puts("Found a luamodule"); }
|
||||||
<C_COMMENT>"\\function" { BEGIN(C_FUNCTION); puts("Found a \\function"); }
|
<C_COMMENT>"\\function" { BEGIN(C_FUNCTION); puts("Found a \\function"); }
|
||||||
<C_COMMENT>"\\desc" { BEGIN(C_DESC); puts("Found a \\desc"); }
|
<C_COMMENT>"\\desc" { BEGIN(C_DESC); puts("Found a \\desc"); }
|
||||||
<C_COMMENT>"\\param" { BEGIN(C_PARAM); puts("Found a \\param"); }
|
<C_COMMENT>"\\param" { BEGIN(C_PARAM); puts("Found a \\param"); }
|
||||||
<C_COMMENT>[ \t\n]* ;
|
<C_COMMENT>[ \t\n]* ;
|
||||||
<C_COMMENT>. ;
|
<C_COMMENT>. ;
|
||||||
|
|
||||||
<C_MODULE>[ \t\n] ;
|
<C_MODULE>[ \t\n] ;
|
||||||
<C_MODULE>{VAR} { BEGIN(C_COMMENT); printf("module name: %s\n", yytext); }
|
<C_MODULE>{VAR} { BEGIN(C_COMMENT); printf("module name: %s\n", yytext); }
|
||||||
<C_MODULE>. ;
|
<C_MODULE>. ;
|
||||||
|
|
||||||
<C_FUNCTION>";" { BEGIN(C_COMMENT); puts("End of function"); }
|
<C_FUNCTION>";" { BEGIN(C_COMMENT); puts("End of function"); }
|
||||||
<C_FUNCTION>{FUNCTEXT} { printf("function text: %s\n", yytext); }
|
<C_FUNCTION>{FUNCTEXT} { printf("function text: %s\n", yytext); }
|
||||||
<C_FUNCTION>. ;
|
<C_FUNCTION>. ;
|
||||||
|
|
||||||
<C_DESC>";" { BEGIN(C_COMMENT); puts("End of desc"); }
|
<C_DESC>";" { BEGIN(C_COMMENT); puts("End of desc"); }
|
||||||
<C_DESC>"\"" { BEGIN(C_STRING); lastState = C_DESC; puts("Found a String"); }
|
<C_DESC>"\"" { BEGIN(C_STRING); lastState = C_DESC; puts("Found a String"); }
|
||||||
<C_DESC>[.\n]+ { printf("desc text: %s\n", yytext); }
|
<C_DESC>[.\n]+ { printf("desc text: %s\n", yytext); }
|
||||||
<C_DESC>. ;
|
<C_DESC>. ;
|
||||||
|
|
||||||
<C_PARAM>";" { BEGIN(C_COMMENT); puts("End of param"); }
|
<C_PARAM>";" { BEGIN(C_COMMENT); puts("End of param"); }
|
||||||
<C_PARAM>"\"" { BEGIN(C_STRING); lastState = C_PARAM; puts("Found a string"); }
|
<C_PARAM>"\"" { BEGIN(C_STRING); lastState = C_PARAM; puts("Found a string"); }
|
||||||
<C_PARAM>[ \t] ;
|
<C_PARAM>[ \t] ;
|
||||||
<C_PARAM>"float" { printf("foud type: %s\n", yytext); }
|
<C_PARAM>"float" { printf("foud type: %s\n", yytext); }
|
||||||
<C_PARAM>"vec" { printf("foud type: %s\n", yytext); }
|
<C_PARAM>"vec" { printf("foud type: %s\n", yytext); }
|
||||||
<C_PARAM>"vector" { printf("foud type: %s\n", yytext); }
|
<C_PARAM>"vector" { printf("foud type: %s\n", yytext); }
|
||||||
<C_PARAM>"ent" { printf("foud type: %s\n", yytext); }
|
<C_PARAM>"ent" { printf("foud type: %s\n", yytext); }
|
||||||
<C_PARAM>"entity" { printf("foud type: %s\n", yytext); }
|
<C_PARAM>"entity" { printf("foud type: %s\n", yytext); }
|
||||||
<C_PARAM>{VAR} { printf("foud name: %s\n", yytext); }
|
<C_PARAM>{VAR} { printf("foud name: %s\n", yytext); }
|
||||||
<C_PARAM>. ;
|
<C_PARAM>. ;
|
||||||
|
|
||||||
<C_STRING>"\"" { BEGIN(lastState); puts("End of String"); }
|
<C_STRING>"\"" { BEGIN(lastState); puts("End of String"); }
|
||||||
<C_STRING>{STRING} { printf("string text: %s\n", yytext); }
|
<C_STRING>{STRING} { printf("string text: %s\n", yytext); }
|
||||||
<C_STRING>. ;
|
<C_STRING>. ;
|
||||||
|
|
||||||
"\n" ;
|
"\n" ;
|
||||||
. ;
|
. ;
|
||||||
%%
|
%%
|
||||||
|
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
|
|
Loading…
Reference in a new issue