Example #1
0
int precedenceParser() {				// hlavni funkce precedencni analyzy

	tStack stack1;
	stackInit(&stack1);

	tStack stack2;
	stackInit(&stack2);

	tOpData temp;

	infix2post(&stack1, &stack2);		// prevedeni vyrazu na postfixovou notaci

	while(stackEmpty(&stack2) != true) {		// prechozeni na druhy zasobnik + kontrolni vypsani

		stackPop(&stack2, &temp);
		stackPush(&stack1, temp);
	}

	int x = reduction(&stack1, &stack2);		// provedeni redukce
	printf("Navratovy typ vyrazu: %d\n", x);

	stackDispose(&stack1);
	stackDispose(&stack2);


	return x;
}
Example #2
0
File: main.c Project: manuts/coding
void main()
{
    stack s;
    stackNew(&s);
    printf("LSize = %d\tASize = %d\n", s.LSize, s.ASize);
    int i;
    for( i = 0; i < 9; i++ )
    {
        stackPush(&s, i*i);
    }
    printf("LSize = %d\tASize = %d\n", s.LSize, s.ASize);
    for( i = 0; i < 7; i++ )
    {
        printf("Pop returns %d\n", stackPop(&s));
    }
    printf("LSize = %d\tASize = %d\n", s.LSize, s.ASize);
    stackDispose(&s);
}