コード例 #1
0
ファイル: labeler.c プロジェクト: trucnguyenlam/getafix
static bp_fun_t find_function(char* varname)
{
    bp_fun_t y;

    for (y = bp_functions; y; y = y->next)
        if (strcmp(varname, y->funname) == 0) return (y);
    common_error("error: the name of the called function does not exist: %s\n", varname);
}
コード例 #2
0
fcppt::string
sge::parse::impl::file_error_string(
	boost::filesystem::path const &_path,
	fcppt::parse::error<
		wchar_t
	> &&_error
)
{
	return
		fcppt::optional::maybe(
			fcppt::from_std_wstring(
				std::move(
					_error.get()
				)
			),
			[
				&_path
			]{
				return
					common_error(
						_path
					)
					+
					FCPPT_TEXT("Failed to convert error message!");
			},
			[
				&_path
			](
				fcppt::string &&_fcppt_error
			)
			{
				return
					common_error(
						_path
					)
					+
					std::move(
						_fcppt_error
					);
			}
		);
}
コード例 #3
0
ファイル: labeler.c プロジェクト: trucnguyenlam/getafix
int main(int argc, char **argv )
{
    if ( argc != 3 )
        common_error("usage: ./a.out FILE_NAME TARGET_LABEL \n");

    line = column = 1;
    if (!(yyin = fopen(argv[1], "r")))
    {
        common_error("file %s not found", argv[1]);
    }
    target_label = argv[2];

    if (yyparse())
    {
        common_error("parse errors encountered");
    }

    fclose(yyin);

    label_program(argv[1]);
}
コード例 #4
0
ファイル: labeler.c プロジェクト: trucnguyenlam/getafix
static void
put_name_numb_fun_locals(void)
{
    bp_fun_t p;
    bp_ident_t z, t;

    for (p = bp_functions; p; p = p->next) {
        for (z = p->locals; z; z = z->next) {
            t = Is_there_var(bp_all_locals, z->varname );
            if (t == NULL)  common_error("error: local variable not found %s\n", z->varname);

            z->varname_replace = t->varname_replace;
        }
    }
}
コード例 #5
0
fcppt::string
sge::parse::impl::file_error_string(
	boost::filesystem::path const &_path,
	fcppt::parse::error<
		char
	> &&_error
)
{
	return
		common_error(
			_path
		)
		+
		fcppt::from_std_string(
			std::move(
				_error.get()
			)
		);
}
コード例 #6
0
ファイル: labeler.c プロジェクト: trucnguyenlam/getafix
static void recursive_set_next_statement(bp_stmt_t start, bp_stmt_t p, bp_stmt_t next_p)
{

    bp_stmt_t temp;

    if (!p) return;

    if (p->next)   p->next_stmt = p->next;
    else           p->next_stmt = next_p;


    switch (p->type)
    {
    case BP_IF:
    case BP_ELSEIF:
    {
        recursive_set_next_statement(start, p->e.c.thenstmt, p->next_stmt);
        recursive_set_next_statement(start, p->e.c.elsestmt, p->next_stmt);
        break;
    }
    case BP_WHILE:
    {
        recursive_set_next_statement(start, p->e.c.thenstmt, p);
        break;
    }
    case BP_GOTO:
    {
        p->next_stmt = find_label(start, p->e.a.label );
        if (p->next_stmt == NULL)  common_error("error: label of goto not found: %s\n", p->e.a.label );

        break;
    }
    }

    recursive_set_next_statement(start, p->next, next_p);
}
コード例 #7
0
ファイル: labeler.c プロジェクト: trucnguyenlam/getafix
static void
clousure_calledmodule(void)
{
    bp_fun_t calledfun, calledfun2, fun, funtemp;
    int ris;

    ris = 1;

    while (ris) {
        ris = 0;
        for (fun = bp_functions; fun; fun = fun->next)
        {
            for (calledfun = fun->calledmodule; calledfun; calledfun = calledfun->next)
            {
                funtemp = find_module(bp_functions, calledfun->funname);
                if (!funtemp) common_error("the function does not exist.\n");
                for (calledfun2 = funtemp->calledmodule; calledfun2; calledfun2 = calledfun2->next)
                    if (insert_module_in_module_list(fun, calledfun2->funname)) ris = 1;
            }
        }
    }

    return;
}
コード例 #8
0
ファイル: pre.c プロジェクト: wuxb45/ADL
static int
pre_recursive_process(FILE * input, char * current_file)
{
	/* TODO: self-include. */
	FILE *include;
	FILE *file_arch;
	FILE *file_code1;

	char buffer[1024];
	char *temp;
	char *include_name;
	int flag;//0:adl, 1:ccode
	int result;
	int fid;
	int line;

	file_arch = config_get_file(CONFIG_FILE_ID_ARCH);
	if(file_arch == NULL){
		return -1;
	}

	file_code1 = config_get_file(CONFIG_FILE_ID_CODE1);
	if(file_code1 == NULL){
		return -1;
	}

	line = 1;
	flag = 0;
	// split into two parts.

	fid = line_register_file(current_file);
	if(fid == 0){
		return 0;
	}

	while (fgets(buffer, 1023, input)) {

		if(flag == 0){
			temp = strchr(buffer, '#');
			if(temp){
				temp[0] = '\n';
				temp[1] = '\0';
			}
		}

		temp = util_trim_front(buffer);


		if (flag == 0 && temp[0] == '@') {	// include
			include_name = util_trim(temp + 1);
			include = fopen(include_name, "r");
			if (include == NULL) {
				common_error("Cannot open include file [%s].\n", temp);
				result = -1;
			}else{
				result = pre_recursive_process(include, include_name);
				fclose(include);
				include = NULL;
			}
			if (result) {
				return result;
			} else {
				line ++;
				continue;
			}
		} else if (strncmp(temp, "%%", 2) == 0) {
			if (flag) {
				fputs(buffer, file_code1);
				fputs("\n", file_arch);
			} else {
				fputs(buffer, file_arch);
			}
			flag = (~flag);
		} else {
			if (flag) {
				fputs(buffer, file_code1);
				fputs("\n", file_arch);
			} else {
				fputs(buffer, file_arch);
			}
		}
		line_register_line(fid, line);
		line ++;

	}
	return 0;
}
コード例 #9
0
 common_error exception() const
 {
   return common_error("", 0);
 }