Eventually gonna squash all of today's work

This commit is contained in:
2022-08-29 04:08:31 +01:00
parent 61efb96fe2
commit a6f0200255
5 changed files with 55 additions and 177 deletions

View File

@@ -15,6 +15,36 @@ int main() {
freeNode(node);
}
{
//test compound (dictionary)
char* idn = "foobar";
char* str = "hello world";
Node* dictionary;
Node* left;
Node* right;
emitNodeCompound(&dictionary, LITERAL_DICTIONARY);
emitNodeLiteral(&left, TO_IDENTIFIER_LITERAL(copyString(idn, strlen(idn)), strlen(idn)) );
emitNodeLiteral(&right, TO_STRING_LITERAL(copyString(str, strlen(str)), strlen(str)) );
//grow the node if needed
if (dictionary->compound.capacity < dictionary->compound.count + 1) {
int oldCapacity = dictionary->compound.capacity;
dictionary->compound.capacity = GROW_CAPACITY(oldCapacity);
dictionary->compound.nodes = GROW_ARRAY(Node, dictionary->compound.nodes, oldCapacity, dictionary->compound.capacity);
}
//store the left and right in the node
Node* pair = NULL;
emitNodePair(&pair, left, right);
dictionary->compound.nodes[dictionary->compound.count++] = *pair;
//the real test
freeNode(dictionary);
}
printf(NOTICE "All good\n" RESET);
return 0;
}