Пример #1
0
int Compiler_compileString(Context* context, const char* str) {
    void* scanner;
    Node* root = 0;

    yylex_init(&scanner);
    yy_scan_string(str, scanner);

    int res = yyparse(scanner, &root);
    yylex_destroy(scanner);
    if (res) return -1;

    res = Compiler_compileRootNode(context, root);
    if (root) Node_delete(root);
    return res;
}
Пример #2
0
int Compiler_compileFile(Context* context, FILE* file) {
    void* scanner;
    Node* root = 0;

    yylex_init(&scanner);
    yyset_in(file, scanner);

    int res = yyparse(scanner, &root);
    yylex_destroy(scanner);
    if (res) return -1;

    res = Compiler_compileRootNode(context, root);
    if (root) Node_delete(root);
    return res;
}
Пример #3
0
void List_remove(List list)
{
	Node node, prev, next;

	assert(list);

	node = list->current;

	if(node == NULL)
		return;

	list->size--;
	prev = node->prev;
	next = node->next;

	Node_delete(node);

	if(prev != NULL)
	{
		if(next != NULL)
		{
			prev->next = next;
			next->prev = prev;
			list->current = next;
			return;
		}

		prev->next = NULL;
		list->tail = prev;
		list->current = prev;
		return;
	}

	if(next != NULL)
	{
		next->prev = NULL;
		list->head = next;
		list->current = next;
		return;
	}

	list->head = NULL;
	list->tail = NULL;
	list->current = NULL;
}