示例#1
0
文件: dpp.c 项目: ageneau/ecl-mirror
void
get_function(void)
{
        function = read_function();
        function_symbol = search_symbol(function, &function_code, 0);
        if (function_symbol == NULL) {
                function_symbol = poolp;
                pushstr("ECL_NIL");
                pushc('\0');
        }
        function_c_name = translate_function(function);
}
示例#2
0
文件: dpp.c 项目: ageneau/ecl-mirror
char *
read_token(void)
{
        int c;
        int left_paren = 0;
        char *p;

        p = poolp;
        c = readc();
        while (isspace(c))
                c = readc();
        do {
                if (c == '(') {
                        left_paren++;
                        pushc(c);
                } else if (c == ')') {
                        if (left_paren == 0) {
                                break;
                        } else {
                                left_paren--;
                                pushc(c);
                        }
                } else if (isspace(c) && left_paren == 0) {
                        do
                                c = readc();
                        while (isspace(c));
                        break;
                } else if (c == '@') {
                        c = readc();
                        if (c == '\'') {
                                (void)read_symbol(0);
                                poolp--;
                        } else if (c == '[') {
                                (void)read_symbol(1);
                                poolp--;
                        } else if (c == '@') {
                                pushc(c);
                        } else {
                                char *name;
                                unreadc(c);
                                poolp = name = read_function();
                                (void)translate_function(poolp);
                        }
                } else {
                        pushc(c);
                }
                c = readc();
        } while (1);
        unreadc(c);
        pushc('\0');
        return(p);
}
示例#3
0
文件: asm.c 项目: cheuk-fung/C--
void asm_translate(struct Syntree_node *root)
{
    if (root == NULL) return ;

    struct Syntree_node *sn;
    for (sn = root; sn; sn = sn->next) {
        switch (sn->nkind) {
            case K_FUNC:
                translate_function(sn);
                break;
            case K_STMT:
                translate_statement(sn);
                break;
            case K_EXPR:
                translate_expression(sn);
        }
    }
}
示例#4
0
文件: dpp.c 项目: ageneau/ecl-mirror
void
main_loop(void)
{
        int c;
        int in_defun=0;
        char *p;

        lineno = 1;

        reset();
        put_lineno();
LOOP:
        c = jump_to_at();
        if (c == ')') {
                if (!in_defun)
                        error("unmatched @) found");
                in_defun = 0;
                putc('}',out);
                reset();
                goto LOOP;
        } else if (c == '\'') {
                char *p;
                poolp = pool;
                p = read_symbol(0);
                pushc('\0');
                fprintf(out,"%s",p);
                goto LOOP;
        }  else if (c == '[') {
                char *p;
                poolp = pool;
                p = read_symbol(1);
                pushc('\0');
                fprintf(out,"%s",p);
                goto LOOP;
        } else if (c != '(') {
                char *p;
                unreadc(c);
                poolp = pool;
                poolp = p = read_function();
                fprintf(out,"%s",translate_function(poolp));
                goto LOOP;
        }
        p = read_token();
        if (strcmp(p, "defun") == 0) {
                if (in_defun)
                        error("@) expected before new function definition");
                in_defun = 1;
                get_function();
                get_lambda_list();
                put_fhead();
                put_lineno();
                c = jump_to_at();
                put_declaration();
                put_lineno();
        } else if (strcmp(p, "return") == 0) {
                tab_save = tab;
                get_return();
                put_return();
        } else
                error_symbol(p);
        goto LOOP;
}