示例#1
0
astree parser_labeled_line(astree optlabel, astree line) {
    astree ret = line;
    if ( optlabel != NULL ) {
        ast_add_child(optlabel, line);
        ret = optlabel;
    }
    return ret;
}
示例#2
0
void	*ast_add_root(void *o)
{
	t_ast *a;
	t_ast *r;

	a = o;
	if (!a)
		return (0);
	if (a->n_children <= 1)
		return (a);
	r = ast_new(">", "");
	ast_add_child(r, a);
	return (r);
}
示例#3
0
astree parser_origin(astree origin, astree num) {
    ast_add_child(origin, num);
    return origin;
}
示例#4
0
astree jump_sub(astree a1, astree a2) {
    ast_add_child(a1,a2);
    return a1;
}
示例#5
0
astree stack_pop(astree a1, astree a2) {
    ast_add_child(a1, a2);
    return a1;
}
示例#6
0
astree sys_trap(astree a1, astree a2) {
    ast_add_child(a1, a2);
    return a1;
}
示例#7
0
astree string_directive(astree a1, astree a2) {
    ast_add_child(a1, a2);
    return a1;
}
示例#8
0
/* 
 * The main routine that takes the parse tree and coordinates all processing
 */
void process_tree(char *aspis_home, char* outpath,
        char * taintspath,
        char* prototypespath,
        char * categories,
        char *filename,
        astp tree) {
    FILE * fout = NULL;
    if (outpath != NULL && !COLLECT_INFO) {
        fout = fopen(outpath, "w");
        if (fout == NULL) {
            die("Cannot write to output");
        }
    } else fout = stdout;

    if (!is_online) {
        printf("\n\n==========================\n");
        printf("|       Parsing AST      |\n");
        printf("==========================\n\n");
    }
    if (tree->type != T_INLINE_HTML && tree->type != T_INLINE_HTML_EQUALS) {
        astp p = ast_new(T_INLINE_HTML, "");
        ast_add_child(p, tree);
        tree = p;
    }
    if (!is_online) ast_print_bfs(stdout, tree);

    if (!is_online) {
        printf("\n\n==========================\n");
        printf("|     Transforming AST     |\n");
        printf("==========================\n\n");
    }
    astp functions_used;
    ast_transform(stdout,aspis_home, taintspath, prototypespath, categories, filename, &tree, &functions_used);

    if (!is_online) {
        printf("\n\n==========================\n");
        printf("|      Improving AST      |\n");
        printf("==========================\n\n");
    }
    ast_improve(stdout, &tree);

    if (!is_online) {
        printf("\n\n==========================\n");
        printf("|         Final AST         |\n");
        printf("==========================\n\n");
    }
    script_stage = 0;
    if (!COLLECT_INFO) ast_print_bfs(fout, tree);

    if (!is_online) {
        printf("\n\n==========================\n");
        printf("| Built-in  Functions used |\n");
        printf("==========================\n\n");
    }
    script_stage = 0;
    if (COLLECT_INFO) {
        FILE * fused = fopen("fused.txt", "a");
        ast_print_bfs(fused, functions_used);
        fclose(fused);
    }

   //let's output the result
   if (fout!=stdout && !is_online ) {
       fflush(fout);
       fclose(fout);
       printf("File (%s) closed\n",outpath);
       char str[1000];
       sprintf(str,"cat %s",outpath);
       printf("--------->%s\n",str);
       if (system(str)==-1) die("cat failed?!");
       printf("\n----------\n");
   }
   
}