WONKY



LOG | FILES | OVERVIEW


F diff --git a/lex/lexer.c b/lex/lexer.c --- a/lex/lexer.c +++ b/lex/lexer.c
{
parse_preproc_line(src,translation_data);
last_line=current_token->line;
+ free(current_token);
}else
{
push_lexing_error("preprocessing directive must be at the beggining of the line",src,translation_data);
+ free(current_token);
while((current_token=get_next_token(src,&chonky[0],0))->type!=KW_NOTYPE)
{
free(current_token);
{
int temp;
size_t current_size;
+ char hold_char;
struct token *ret;
struct automata_entry *current_state;
}
return ret;
}
+ char src_getc(struct Source_File *src,char skip_line_splice)
+ {
+ superhack:
+ if(src->src[src->where_in_src]=='\\' && skip_line_splice)
+ {
+ if(src->where_in_src < src->src_size-1 && src->src[src->where_in_src+1]=='\n')
+ {
+ ++src->where_in_src;
+ ++src->which_row;
+ src->which_column=0;
+ goto superhack;
+ }else
+ {
+ return '\\';
+ }
+ }else
+ {
+ if(src->src[src->where_in_src]=='\n')
+ {
+ ++src->which_row;
+ src->which_column=0;
+ goto superhack;
+ }else
+ {
+ ++src->which_column;
+ }
+ return src->src[src->where_in_src++];
+ }
+ }
struct token* copy_token(struct token *src)
{
struct token *cpy;
void delete_source_file(struct Source_File *src)
{
delete_source_name(src->src_name);
+ free(src->src);
free(src);
}
void delete_source_name(struct Source_Name *name)
F diff --git a/lex/lexer.h b/lex/lexer.h --- a/lex/lexer.h +++ b/lex/lexer.h
void chomp(struct Translation_Data *translation_data);
enum KEYWORDS kw_get(struct Translation_Data *translation_data);
+ char src_getc(struct Source_File *src,char skip_line_splice);
void delete_source_file(struct Source_File *src);
void delete_source_name(struct Source_Name *name);
F diff --git a/lex/preprocessing.c b/lex/preprocessing.c --- a/lex/preprocessing.c +++ b/lex/preprocessing.c
push_lexing_error("unmatched elif",src,translation_data);
return;
default:
+ free(hold);
/*TODO error*/
push_lexing_error("expected a preprocessing directive",src,translation_data);
return;
{
/*TODO error*/
push_lexing_error("file in include directive not found",src,translation_data);
+ free(hold);
return;
}
}
if(src->where_in_src==src->src_size)
{
/*TODO error*/
+ free(hold);
return;
}
/*skip the >*/
{
/*TODO error*/
push_lexing_error("file in include directive not found",src,translation_data);
+ free(hold);
return;
}
{
/*TODO error*/
push_lexing_error("include error",src,translation_data);
+ free(hold);
return;
}
temp_src=*src;
hold_token=preproc_find_else(src,translation_data,1);
+
temp_src.src_size=src->where_in_src;
just_in_case=src->src[src->where_in_src];
src->src[src->where_in_src]='\0';
src->src[src->where_in_src]=just_in_case;
+ if(hold_token!=NULL)
+ free(hold_token);
do
+ {
hold_token=preproc_find_else(src,translation_data,0);
- while(hold_token && !has_new_errors(translation_data));
+ if(hold_token)
+ free(hold_token);
+ else
+ break;
+ }while(!has_new_errors(translation_data));
if(hold_token!=NULL)
{
+ free(hold_token);
push_lexing_error("could not find matching #else, #elif or #endif",src,translation_data);
}
}
hold_token=get_next_token(src,&chonky[0],0);
if(hold_token==NULL || hold_token->type!=KW_ID)
{
+ free(hold_token);
push_lexing_error("expected an id here",src,translation_data);
chase_new_line(src,translation_data);
+ return;
}else
{
if(Map_Check(translation_data->macros,hold_token->data,hold_token->data_size))
preproc_lex_first_part(src,translation_data);
}else
{
+ free(hold_token);
+
hold_token=preproc_find_else(src,translation_data,1);
+
if(hold_token!=NULL && hold_token->type==PKW_ELIF)
{
parse_preproc_if_line(src,translation_data);
preproc_find_else(src,translation_data,0);
preproc_lex_first_part(src,translation_data);
}
+
+ free(hold_token);
}
}
{
push_lexing_error("expected an id here",src,translation_data);
chase_new_line(src,translation_data);
+ free(hold_token);
+ return;
}else
{
if(!Map_Check(translation_data->macros,hold_token->data,hold_token->data_size))
{
+ free(hold_token);
preproc_lex_first_part(src,translation_data);
}else
{
+ free(hold_token);
+
hold_token=preproc_find_else(src,translation_data,1);
if(hold_token!=NULL && hold_token->type==PKW_ELIF)
{
preproc_find_else(src,translation_data,0);
preproc_lex_first_part(src,translation_data);
}
+
+ free(hold_token);
}
}
if(id->type!=KW_ID)
{
push_lexing_error("expected an id here",src,translation_data);
- return;
}else
{
hold_macro=Map_Check(translation_data->macros,id->data,id->data_size);
Map_Remove(translation_data->macros,id->data,id->data_size);
}
}
+ free(id);
chase_new_line(src,translation_data);
}
void delete_macro(void *macro)
free(AS_MACRO(macro)->macro_name);
while(AS_MACRO(macro)->macro_tokens->size>0)
free(Queue_Pop(AS_MACRO(macro)->macro_tokens));
+ free(AS_MACRO(macro)->macro_tokens);
Map_Map(AS_MACRO(macro)->arguments,free);
+ free(AS_MACRO(macro)->arguments);
free(macro);
#undef AS_MACRO
}
F diff --git a/main.c b/main.c --- a/main.c +++ b/main.c
{
print_errors(stdout,program->errors);
}
+ delete_command_arguments(command_arguments);
delete_program(program);
return 1;
}else if(command_arguments->print_ast && !command_arguments->is_quiet)
+ delete_command_arguments(command_arguments);
delete_program(program);
return 0;
}
F diff --git a/misc/gcc_arguments.c b/misc/gcc_arguments.c --- a/misc/gcc_arguments.c +++ b/misc/gcc_arguments.c
struct Queue *source_names;
ret=malloc(sizeof(struct Command_Arguments));
- ret->print_ast=ret->print_tokens=ret->transpile_to_js=0;
+ ret->print_ast=ret->print_tokens=ret->transpile_to_js=ret->is_quiet=0;
ret->output_file=ret->javascript_extern_file=NULL;
source_names=malloc(sizeof(struct Queue));
}
+ void delete_command_arguments(struct Command_Arguments *args)
+ {
+ if(args->output_file!=NULL)
+ fclose(args->output_file);
+ if(args->javascript_extern_file!=NULL)
+ fclose(args->javascript_extern_file);
+
+ free(args->source_names);
+ free(args);
+ }
+
#endif
F diff --git a/misc/gcc_arguments.h b/misc/gcc_arguments.h --- a/misc/gcc_arguments.h +++ b/misc/gcc_arguments.h
};
struct Command_Arguments* parse_command_arguments(char **argv);
+ void delete_command_arguments(struct Command_Arguments *args);
#endif
F diff --git a/misc/map.c b/misc/map.c --- a/misc/map.c +++ b/misc/map.c
*/
free(current_node);
}
+ /*this is where the root is at- we don't delete it , but we must free the last stack node*/
+ Stack_Pop(&nodes);
}
F diff --git a/misc/stack.h b/misc/stack.h --- a/misc/stack.h +++ b/misc/stack.h
#include<stdlib.h>
typedef struct Stack Stack;
+ struct Stack_Node
+ {
+ struct Stack_Node *next;
+ void *data;
+ };
struct Stack
{
- struct Stack_Node
- {
- struct Stack_Node *next;
- void *data;
- }*first;
- size_t size;
+ struct Stack_Node *first;
+ size_t size;
};
void Stack_Init(Stack *stack);
F diff --git a/parse/parse_declaration.c b/parse/parse_declaration.c --- a/parse/parse_declaration.c +++ b/parse/parse_declaration.c
while(1)
{
if(get_and_check(translation_data,KW_SEMI_COLUMN))
- return;
+ goto finish;
hold=parse_declarator(translation_data,scope,prototype);
Queue_Push(where_to_push,get_function_definition_tree(scope,(struct Denoted_Function*)hold));
Scope_Push(scope,hold,translation_data);
- free(prototype);
- return;
+ goto finish;
}
Queue_Push(where_to_push,get_function_declaration_tree(scope,(struct Denoted_Function*)hold));
/*TODO error*/
Queue_Push(where_to_push,get_declaration_error_tree(hold));
push_translation_error("declaration expected",translation_data);
- free(prototype);
/*search for end of erronous declaration*/
while(!get_and_check(translation_data,KW_SEMI_COLUMN))
{
free(Queue_Pop(translation_data->tokens));
}
- return;
+ goto finish;
}
Scope_Push(scope,hold,translation_data);
{
if(get_and_check(translation_data,KW_SEMI_COLUMN))
{
- return;
+ goto finish;
}else
{
/*TODO error*/
Queue_Push(where_to_push,get_declaration_error_tree(NULL));
push_translation_error("semi column expected",translation_data);
- return;
+ goto finish;
}
}
}
+
+ finish:
free(prototype);
}
struct Denoted* parse_declarator(struct Translation_Data *translation_data,struct Scope *scope,struct Denotation_Prototype *prototype)
{
struct Denoted_Base *temp;
+ struct Denoted *ret;
temp=get_denoted_base(prototype);
parse_declarator_inner(translation_data,scope,temp);
- return extract_denoted(temp,prototype,0);
+ ret=extract_denoted(temp,prototype,0);
+ delete_denoted_base(temp);
+ return ret;
}
F diff --git a/semantics/ast.c b/semantics/ast.c --- a/semantics/ast.c +++ b/semantics/ast.c
{
if(object_declaration->initializer!=NULL)
delete_ast(object_declaration->initializer);
+ free(object_declaration);
}
void delete_ast_function_definition(struct AST_Function_Definition *function_definition)
F diff --git a/semantics/program.c b/semantics/program.c --- a/semantics/program.c +++ b/semantics/program.c
free(program->source_files);
-
while(program->errors->size>0)
delete_translation_error(Queue_Pop(program->errors));
+ free(program->errors);
+
+
delete_scope(program->externs);
/*BEWARE*/
- Map_Map(program->types,free);
+ Map_Map(program->types,delete_type);
Map_Destroy(program->types);
free(program->types);
Map_Map(translation_data->macros,delete_macro);
Map_Destroy(translation_data->macros);
free(translation_data->macros);
+
+ free(translation_data);
}
void assimilate_translation_data(struct Program *program,struct Translation_Data *translation_data)
F diff --git a/semantics/type.c b/semantics/type.c --- a/semantics/type.c +++ b/semantics/type.c
{
ret->arguments[i]=(struct Denoted_Object*)Queue_Pop(parameters);
}
+ free(parameters);
ret=(struct Type_Function*)type_check_and_push((struct Type*)ret,return_type->node,sizeof(struct Type_Function));
}
free(su);
}
+
+ void delete_type(void *type)
+ {
+ if(((struct Type*)type)->specifier!=TS_FUNC)
+ {
+ free(type);
+ }else
+ {
+ delete_normal_scope(AS_TYPE_FUNC_PTR(type)->function_prototype_scope);
+ free(AS_TYPE_FUNC_PTR(type)->arguments);
+ free(type);
+ }
+ }
#endif
F diff --git a/semantics/type.h b/semantics/type.h --- a/semantics/type.h +++ b/semantics/type.h
void delete_enum(struct Enum *enumeration);
void delete_struct_union(struct Struct_Union *su);
-
+ void delete_type(void *type);
char is_type(struct Translation_Data *translation_data,struct Scope *scope);
size_t get_type_size(struct Type *type);
F diff --git a/semantics/type.hh b/semantics/type.hh --- a/semantics/type.hh +++ b/semantics/type.hh
#define CHAR_SIZE 1
#define FLOAT_SIZE 4
#define DOUBLE_SIZE 8
+
+
#define AS_BASIC_TYPE_PTR(x) ((struct Type_Basic*)x)
#define AS_STRUCT_UNION_PTR(x) ((struct Type_Struct_Union*)x)
#define AS_TYPE_PTR_PTR(x) ((struct Type_Pointer*)x)
#define AS_TYPE_ARR_PTR(x) ((struct Type_Array*)x)
#define AS_TYPE_ENUM_PTR(x) ((struct Type_Enum*)x)
+ #define AS_TYPE_FUNC_PTR(x) ((struct Type_Function*)x)
/*this isn't just type-specifier :DD*/
enum Type_Specifier
F diff --git a/tests/test.c b/tests/test.c --- a/tests/test.c +++ b/tests/test.c
int main()
{
int A[2][3][4];
- const int * const * volatile a;
+ const int * const * volatile a[2][3];
const int * const * volatile b;
- struct a;
- struct a c;
+ int aa;
+ int ab;
+ int ac;
+ int ad;
+ int ae;
+ int af;
+ int ag;
+ int ah;
+ int ai;
+ int aj;
+ int ak;
+ int al;
+ int am;
+ int an;
+ int ao;
+ int ap;
+ int aq;
+ int ar;
+ int as;
+ int at;
+ int au;
+ int av;
+ int aw;
+ int ax;
+ int ay;
+ int az;
+ int ba;
+ int bb;
+ int bc;
+ int bd;
+ int be;
+ int bf;
+ int bg;
+ int bh;
+ int bi;
+ int bj;
+ int bk;
+ int bl;
+ int bm;
+ int bn;
+ int bo;
+ int bp;
+ int bq;
+ int br;
+ int bs;
+ int bt;
+ int bu;
+ int bv;
+ int bw;
+ int bx;
+ int by;
+ int bz;
+ int ca;
+ int cb;
+ int cc;
+ int cd;
+ int ce;
+ int cf;
+ int cg;
+ int ch;
+ int ci;
+ int cj;
+ int ck;
+ int cl;
+ int cm;
+ int cn;
+ int co;
+ int cp;
+ int cq;
+ int cr;
+ int cs;
+ int ct;
+ int cu;
+ int cv;
+ int cw;
+ int cx;
+ int cy;
+ int cz;
+ int da;
+ int db;
+ int dc;
+ int dd;
+ int de;
+ int df;
+ int dg;
+ int dh;
+ int di;
+ int dj;
+ int dk;
+ int dl;
+ int dm;
+ int dn;
+ int do0;
+ int dp;
+ int dq;
+ int dr;
+ int ds;
+ int dt;
+ int du;
+ int dv;
+ int dw;
+ int dx;
+ int dy;
+ int dz;
+ int ea;
+ int eb;
+ int ec;
+ int ed;
+ int ee;
+ int ef;
+ int eg;
+ int eh;
+ int ei;
+ int ej;
+ int ek;
+ int el;
+ int em;
+ int en;
+ int eo;
+ int ep;
+ int eq;
+ int er;
+ int es;
+ int et;
+ int eu;
+ int ev;
+ int ew;
+ int ex;
+ int ey;
+ int ez;
+ int fa;
+ int fb;
+ int fc;
+ int fd;
+ int fe;
+ int ff;
+ int fg;
+ int fh;
+ int fi;
+ int fj;
+ int fk;
+ int fl;
+ int fm;
+ int fn;
+ int fo;
+ int fp;
+ int fq;
+ int fr;
+ int fs;
+ int ft;
+ int fu;
+ int fv;
+ int fw;
+ int fx;
+ int fy;
+ int fz;
+ int ga;
+ int gb;
+ int gc;
+ int gd;
+ int ge;
+ int gf;
+ int gg;
+ int gh;
+ int gi;
+ int gj;
+ int gk;
+ int gl;
+ int gm;
+ int gn;
+ int go;
+ int gp;
+ int gq;
+ int gr;
+ int gs;
+ int gt;
+ int gu;
+ int gv;
+ int gw;
+ int gx;
+ int gy;
+ int gz;
+ int ha;
+ int hb;
+ int hc;
+ int hd;
+ int he;
+ int hf;
+ int hg;
+ int hh;
+ int hi;
+ int hj;
+ int hk;
+ int hl;
+ int hm;
+ int hn;
+ int ho;
+ int hp;
+ int hq;
+ int hr;
+ int hs;
+ int ht;
+ int hu;
+ int hv;
+ int hw;
+ int hx;
+ int hy;
+ int hz;
+ int ia;
+ int ib;
+ int ic;
+ int id;
+ int ie;
+ int iff;
+ int ig;
+ int ih;
+ int ii;
+ int ij;
+ int ik;
+ int il;
+ int im;
+ int in;
+ int io;
+ int ip;
+ int iq;
+ int ir;
+ int is;
+ int it;
+ int iu;
+ int iv;
+ int iw;
+ int ix;
+ int iy;
+ int iz;
+ int ja;
+ int jb;
+ int jc;
+ int jd;
+ int je;
+ int jf;
+ int jg;
+ int jh;
+ int ji;
+ int jj;
+ int jk;
+ int jl;
+ int jm;
+ int jn;
+ int jo;
+ int jp;
+ int jq;
+ int jr;
+ int js;
+ int jt;
+ int ju;
+ int jv;
+ int jw;
+ int jx;
+ int jy;
+ int jz;
+ int ka;
+ int kb;
+ int kc;
+ int kd;
+ int ke;
+ int kf;
+ int kg;
+ int kh;
+ int ki;
+ int kj;
+ int kk;
+ int kl;
+ int km;
+ int kn;
+ int ko;
+ int kp;
+ int kq;
+ int kr;
+ int ks;
+ int kt;
+ int ku;
+ int kv;
+ int kw;
+ int kx;
+ int ky;
+ int kz;
+ int la;
+ int lb;
+ int lc;
+ int ld;
+ int le;
+ int lf;
+ int lg;
+ int lh;
+ int li;
+ int lj;
+ int lk;
+ int ll;
+ int lm;
+ int ln;
+ int lo;
+ int lp;
+ int lq;
+ int lr;
+ int ls;
+ int lt;
+ int lu;
+ int lv;
+ int lw;
+ int lx;
+ int ly;
+ int lz;
+ int ma;
+ int mb;
+ int mc;
+ int md;
+ int me;
+ int mf;
+ int mg;
+ int mh;
+ int mi;
+ int mj;
+ int mk;
+ int ml;
+ int mm;
+ int mn;
+ int mo;
+ int mp;
+ int mq;
+ int mr;
+ int ms;
+ int mt;
+ int mu;
+ int mv;
+ int mw;
+ int mx;
+ int my;
+ int mz;
+ int na;
+ int nb;
+ int nc;
+ int nd;
+ int ne;
+ int nf;
+ int ng;
+ int nh;
+ int ni;
+ int nj;
+ int nk;
+ int nl;
+ int nm;
+ int nn;
+ int no;
+ int np;
+ int nq;
+ int nr;
+ int ns;
+ int nt;
+ int nu;
+ int nv;
+ int nw;
+ int nx;
+ int ny;
+ int nz;
+ int oa;
+ int ob;
+ int oc;
+ int od;
+ int oe;
+ int of;
+ int og;
+ int oh;
+ int oi;
+ int oj;
+ int ok;
+ int ol;
+ int om;
+ int on;
+ int oo;
+ int op;
+ int oq;
+ int or;
+ int os;
+ int ot;
+ int ou;
+ int ov;
+ int ow;
+ int ox;
+ int oy;
+ int oz;
+ int pa;
+ int pb;
+ int pc;
+ int pd;
+ int pe;
+ int pf;
+ int pg;
+ int ph;
+ int pi;
+ int pj;
+ int pk;
+ int pl;
+ int pm;
+ int pn;
+ int po;
+ int pp;
+ int pq;
+ int pr;
+ int ps;
+ int pt;
+ int pu;
+ int pv;
+ int pw;
+ int px;
+ int py;
+ int pz;
+ int qa;
+ int qb;
+ int qc;
+ int qd;
+ int qe;
+ int qf;
+ int qg;
+ int qh;
+ int qi;
+ int qj;
+ int qk;
+ int ql;
+ int qm;
+ int qn;
+ int qo;
+ int qp;
+ int qq;
+ int qr;
+ int qs;
+ int qt;
+ int qu;
+ int qv;
+ int qw;
+ int qx;
+ int qy;
+ int qz;
+ int ra;
+ int rb;
+ int rc;
+ int rd;
+ int re;
+ int rf;
+ int rg;
+ int rh;
+ int ri;
+ int rj;
+ int rk;
+ int rl;
+ int rm;
+ int rn;
+ int ro;
+ int rp;
+ int rq;
+ int rr;
+ int rs;
+ int rt;
+ int ru;
+ int rv;
+ int rw;
+ int rx;
+ int ry;
+ int rz;
+ int sa;
+ int sb;
+ int sc;
+ int sd;
+ int se;
+ int sf;
+ int sg;
+ int sh;
+ int si;
+ int sj;
+ int sk;
+ int sl;
+ int sm;
+ int sn;
+ int so;
+ int sp;
+ int sq;
+ int sr;
+ int ss;
+ int st;
+ int su;
+ int sv;
+ int sw;
+ int sx;
+ int sy;
+ int sz;
+ int ta;
+ int tb;
+ int tc;
+ int td;
+ int te;
+ int tf;
+ int tg;
+ int th;
+ int ti;
+ int tj;
+ int tk;
+ int tl;
+ int tm;
+ int tn;
+ int to;
+ int tp;
+ int tq;
+ int tr;
+ int ts;
+ int tt;
+ int tu;
+ int tv;
+ int tw;
+ int tx;
+ int ty;
+ int tz;
+ int ua;
+ int ub;
+ int uc;
+ int ud;
+ int ue;
+ int uf;
+ int ug;
+ int uh;
+ int ui;
+ int uj;
+ int uk;
+ int ul;
+ int um;
+ int un;
+ int uo;
+ int up;
+ int uq;
+ int ur;
+ int us;
+ int ut;
+ int uu;
+ int uv;
+ int uw;
+ int ux;
+ int uy;
+ int uz;
+ int va;
+ int vb;
+ int vc;
+ int vd;
+ int ve;
+ int vf;
+ int vg;
+ int vh;
+ int vi;
+ int vj;
+ int vk;
+ int vl;
+ int vm;
+ int vn;
+ int vo;
+ int vp;
+ int vq;
+ int vr;
+ int vs;
+ int vt;
+ int vu;
+ int vv;
+ int vw;
+ int vx;
+ int vy;
+ int vz;
+ int wa;
+ int wb;
+ int wc;
+ int wd;
+ int we;
+ int wf;
+ int wg;
+ int wh;
+ int wi;
+ int wj;
+ int wk;
+ int wl;
+ int wm;
+ int wn;
+ int wo;
+ int wp;
+ int wq;
+ int wr;
+ int ws;
+ int wt;
+ int wu;
+ int wv;
+ int ww;
+ int wx;
+ int wy;
+ int wz;
+ int xa;
+ int xb;
+ int xc;
+ int xd;
+ int xe;
+ int xf;
+ int xg;
+ int xh;
+ int xi;
+ int xj;
+ int xk;
+ int xl;
+ int xm;
+ int xn;
+ int xo;
+ int xp;
+ int xq;
+ int xr;
+ int xs;
+ int xt;
+ int xu;
+ int xv;
+ int xw;
+ int xx;
+ int xy;
+ int xz;
+ int ya;
+ int yb;
+ int yc;
+ int yd;
+ int ye;
+ int yf;
+ int yg;
+ int yh;
+ int yi;
+ int yj;
+ int yk;
+ int yl;
+ int ym;
+ int yn;
+ int yo;
+ int yp;
+ int yq;
+ int yr;
+ int ys;
+ int yt;
+ int yu;
+ int yv;
+ int yw;
+ int yx;
+ int yy;
+ int yz;
+ int za;
+ int zb;
+ int zc;
+ int zd;
+ int ze;
+ int zf;
+ int zg;
+ int zh;
+ int zi;
+ int zj;
+ int zk;
+ int zl;
+ int zm;
+ int zn;
+ int zo;
+ int zp;
+ int zq;
+ int zr;
+ int zs;
+ int zt;
+ int zu;
+ int zv;
+ int zw;
+ int zx;
+ int zy;
+ int zz;
return 1+1;
}
F diff --git a/tests/test3.c b/tests/test3.c --- a/tests/test3.c +++ b/tests/test3.c
char asdf;
#endif
- struct A
- {
- int a:1;
- }a;
int external_int;
int static_int;
int fib(int n)
int *a;
external_int++;
alert(fib(10));
+ +1;
return 0;
}