var_decl_t parse_para(tokenizer_t t) { char * filename = cur_tok(t).filename; int line = cur_tok(t).line_num; eat_it(t, TOK_INT); char * f0 = parse_identifier(t); char *f = (char *)malloc(sizeof(char) * strlen(f0) + 1); strcpy(f, f0); return mk_var_decl(filename, line, f); }
var_decl_t parse_param(tokenizer_t t) { eat_it(t, TOK_INT); struct token tok = cur_tok(t); char *v = (char *) malloc (sizeof(char) * strlen(tok.name)); strcpy(v, tok.name); eat_it(t, TOK_ID); return mk_var_decl(t->filename, t->line, v); }
var_decl_t parse_decl(tokenizer_t t) { eat_it(t, TOK_INT); char* v; v = strdup(cur_tok(t).name); eat_it(t, TOK_ID); eat_it(t, TOK_SEMICOLON); return mk_var_decl(t->filename, t->line, v); }
var_decl_list_t parse_var_decl(tokenizer_t t) { var_decl_list_t d = mk_var_decl_list(); char * filename = cur_tok(t).filename; int line = cur_tok(t).line_num; while(cur_tok(t).kind == TOK_INT) { parse_type_expr(t); char * f =(char *)malloc(sizeof(char) * 100); strcpy(f, parse_identifier(t)); var_decl_t x = mk_var_decl(filename, line, f); var_decl_list_add(d, x); eat_it(t, TOK_SEMICOLON); } return d; }