Exemple #1
0
STATUS infix2postfix(char *in, char *output)
{
    struct Stack *S = NULL;
    char *p = in;
    element_type data;

    while (*p) {
        if (isdigit(*p)) {
            //	out_c(*p, &output);
            *output++ = *p;
        } else if (*p == '(') {
            push(&S, *p);
        } else if (*p == ')') {
            *output = ' ';
            while (1) {
                pop(&S, &data);
                if (data && data != '(') {
                    out_c(data, &output);
                } else {
                    break;
                }
            }
        } else if (*p == '+' || *p == '-' || *p == '*' || *p == '/') {
            while (1) {
                if ((top(S, &data) == SUCCESS) && (getPriority(*p) <= getPriority(data))) {
                    pop(&S, &data);

                    if (*p != '(' && *p != ')')
                        out_c(data, &output);
                } else {
                    *output++ = ' ';
                    push(&S, *p);
                    break;
                }
            }
        } else if (*p == ' ' || *p == '\t') {
            out_c(*p, &output);
        }

        ++p;
    }

    for (;;) {
        if (top(S, &data) != SUCCESS)
            break;

        pop(&S, &data);
        if (data != '(' && data != ')')
            out_c(data, &output);
    }

    return SUCCESS;
}
Exemple #2
0
static void out_const_str(const unsigned char /*CONST_VAR*/ *str) {
    const unsigned char *c = str;
    unsigned char tmp;
    while((tmp = CONST_READ_UI8(c++))!='\0') {
        out_c(tmp);
    }
}
Exemple #3
0
static char get_dynamic(struct args_t *args)
{
    uint16_t size = args->size;

    if (size == 0)
    {
	out_c('0');
	return 1;
    }

    while (size--)
    {
	out_array();
	out_c('\n');
    }
    return 1;
}
Exemple #4
0
static char get_dynamic(struct args_t *args)
{
    uint32_t i = 0;
    uint16_t size = 1000;

    if (size == 0)
        out_c('0');
    while (i++ < size)
        out_str(array);
    return 1;
}
Exemple #5
0
static char doGet(struct args_t *args) {
	out_uint(TIME_MILLIS);
	out_c('\n');
	return 1;
}
Exemple #6
0
static char get_dynamic_small(struct args_t *args)
{
    out_c('0');
    return 1;
}