Example #1
0
File: IoLexer.c Project: Akiyah/io
void IoLexer_clear(IoLexer *self)
{
	LIST_FOREACH(self->tokenStream, i, t, IoToken_free((IoToken *)t) );
	List_removeAll(self->tokenStream);

	Stack_clear(self->posStack);
	Stack_clear(self->tokenStack);

	self->current = self->s;
	self->resultIndex = 0;
	self->maxChar = 0;
	self->errorToken = NULL;
}
Example #2
0
int main()
{
    struct Stack * s = Stack_create(true);

    Stack_push(s, Obj_bool_create(true));
    Stack_push(s, Obj_char_create('A'));
    Stack_push(s, Obj_int_create(42));
    Stack_push(s, Obj_double_create(1234.5678));
    printf("POP %f\n", *(double*)Stack_pop(s));
    printf("POP %d\n", *(int*)Stack_pop(s));
    printf("TOP %c\n", *(char*)Stack_top(s));
    printf("TOP %c\n", *(char*)Stack_top(s));

    Stack_clear(s);

    printf("EMPTY? %d\n", (int)Stack_isEmpty(s));

    Stack_push(s, Obj_bool_create(false));
    printf("EMPTY? %d\n", (int)Stack_isEmpty(s));
    Stack_push(s, Obj_char_create('B'));
    printf("POP %c\n", *(char*)Stack_pop(s));
    Stack_push(s, Obj_int_create(666));
    printf("POP %d\n", *(int*)Stack_pop(s));
    Stack_push(s, Obj_double_create(321.654));
    printf("TOP %f\n", *(double*)Stack_top(s));

    Stack_delete(s);
    s = NULL;

    return EXIT_SUCCESS;
}
Example #3
0
int main(int argc, char *argv[])
{
    struct Stack *stack = Stack_create(250);

    Stack_push(stack, "David");
    Stack_push(stack, "Raymond");
    Stack_push(stack, "Bryan");
    printf("length: %d\n", Stack_length(stack));
    printf("%s\n", Stack_peek(stack));
    char *popped = Stack_pop(stack);
    printf("The popped element is: %s\n", popped);
    printf("%s\n", Stack_peek(stack));
    Stack_push(stack, "Cynthia");
    printf("%s\n", Stack_peek(stack));
    Stack_clear(stack);
    printf("length: %d\n", Stack_length(stack));
    printf("%s\n", Stack_peek(stack));
    Stack_push(stack, "Clayton");
    printf("%s\n", Stack_peek(stack));

    Stack_destroy(stack);    
    return 0;
}
Example #4
0
File: IoCoroutine.c Project: jdp/io
void IoCoroutine_clearStack(IoCoroutine *self)
{
	Stack_clear(DATA(self)->ioStack);
}