Add AST node field name with no suffix when unique - #22

This commit is contained in:
josh committed 2024-04-22 21:50:26 -04:00
1 parent cb06a56f81
commit c7a18ef821
5 files changed
+96 -70

No files matched your search

+29 -28
View File
@@ -11,44 +11,45 @@ int main()
assert_eq(P_SUCCESS, p_parse(&context));
Start * start = p_result(&context);
assert(start->pItems1 != NULL);
Items * items = start->pItems1;
assert(items->pItem1 != NULL);
assert(items->pItem1->pToken1 != NULL);
assert_eq(TOKEN_a, items->pItem1->pToken1->token);
assert_eq(11, items->pItem1->pToken1->pvalue);
assert(items->pItemsMore2 != NULL);
ItemsMore * itemsmore = items->pItemsMore2;
assert(itemsmore->pItem2 != NULL);
assert(itemsmore->pItem2->pItem2 != NULL);
assert(itemsmore->pItem2->pItem2->pItem2 != NULL);
assert(itemsmore->pItem2->pItem2->pItem2->pToken1 != NULL);
assert_eq(TOKEN_b, itemsmore->pItem2->pItem2->pItem2->pToken1->token);
assert_eq(22, itemsmore->pItem2->pItem2->pItem2->pToken1->pvalue);
assert(itemsmore->pItemsMore3 != NULL);
itemsmore = itemsmore->pItemsMore3;
assert(itemsmore->pItem2 != NULL);
assert(itemsmore->pItem2->pToken1 != NULL);
assert_eq(TOKEN_b, itemsmore->pItem2->pToken1->token);
assert_eq(22, itemsmore->pItem2->pToken1->pvalue);
assert(itemsmore->pItemsMore3 == NULL);
assert(start->pItems != NULL);
Items * items = start->pItems;
assert(items->pItem != NULL);
assert(items->pItem->pToken1 != NULL);
assert_eq(TOKEN_a, items->pItem->pToken1->token);
assert_eq(11, items->pItem->pToken1->pvalue);
assert(items->pItemsMore != NULL);
ItemsMore * itemsmore = items->pItemsMore;
assert(itemsmore->pItem != NULL);
assert(itemsmore->pItem->pItem != NULL);
assert(itemsmore->pItem->pItem->pItem != NULL);
assert(itemsmore->pItem->pItem->pItem->pToken1 != NULL);
assert_eq(TOKEN_b, itemsmore->pItem->pItem->pItem->pToken1->token);
assert_eq(22, itemsmore->pItem->pItem->pItem->pToken1->pvalue);
assert(itemsmore->pItemsMore != NULL);
itemsmore = itemsmore->pItemsMore;
assert(itemsmore->pItem != NULL);
assert(itemsmore->pItem->pToken1 != NULL);
assert_eq(TOKEN_b, itemsmore->pItem->pToken1->token);
assert_eq(22, itemsmore->pItem->pToken1->pvalue);
assert(itemsmore->pItemsMore == NULL);
input = "";
p_context_init(&context, (uint8_t const *)input, strlen(input));
assert_eq(P_SUCCESS, p_parse(&context));
start = p_result(&context);
assert(start->pItems1 == NULL);
assert(start->pItems == NULL);
input = "2 1";
p_context_init(&context, (uint8_t const *)input, strlen(input));
assert_eq(P_SUCCESS, p_parse(&context));
start = p_result(&context);
assert(start->pItems1 != NULL);
assert(start->pItems1->pItem1 != NULL);
assert(start->pItems1->pItem1->pDual1 != NULL);
assert(start->pItems1->pItem1->pDual1->pTwo1 != NULL);
assert(start->pItems1->pItem1->pDual1->pOne2 != NULL);
assert(start->pItems1->pItem1->pDual1->pTwo2 == NULL);
assert(start->pItems1->pItem1->pDual1->pOne1 == NULL);
assert(start->pItems != NULL);
assert(start->pItems->pItem != NULL);
assert(start->pItems->pItem->pDual != NULL);
assert(start->pItems->pItem->pDual->pTwo1 != NULL);
assert(start->pItems->pItem->pDual->pOne2 != NULL);
assert(start->pItems->pItem->pDual->pTwo2 == NULL);
assert(start->pItems->pItem->pDual->pOne1 == NULL);
return 0;
}
+29 -28
View File
@@ -15,42 +15,43 @@ unittest
assert_eq(P_SUCCESS, p_parse(&context));
Start * start = p_result(&context);
assert(start.pItems1 !is null);
Items * items = start.pItems1;
assert(items.pItem1 !is null);
assert(items.pItem1.pToken1 !is null);
assert_eq(TOKEN_a, items.pItem1.pToken1.token);
assert_eq(11, items.pItem1.pToken1.pvalue);
assert(items.pItemsMore2 !is null);
ItemsMore * itemsmore = items.pItemsMore2;
assert(itemsmore.pItem2 !is null);
assert(itemsmore.pItem2.pItem2 !is null);
assert(itemsmore.pItem2.pItem2.pItem2 !is null);
assert(itemsmore.pItem2.pItem2.pItem2.pToken1 !is null);
assert_eq(TOKEN_b, itemsmore.pItem2.pItem2.pItem2.pToken1.token);
assert_eq(22, itemsmore.pItem2.pItem2.pItem2.pToken1.pvalue);
assert(itemsmore.pItemsMore3 !is null);
itemsmore = itemsmore.pItemsMore3;
assert(itemsmore.pItem2 !is null);
assert(itemsmore.pItem2.pToken1 !is null);
assert_eq(TOKEN_b, itemsmore.pItem2.pToken1.token);
assert_eq(22, itemsmore.pItem2.pToken1.pvalue);
assert(itemsmore.pItemsMore3 is null);
assert(start.pItems !is null);
Items * items = start.pItems;
assert(items.pItem !is null);
assert(items.pItem.pToken1 !is null);
assert_eq(TOKEN_a, items.pItem.pToken1.token);
assert_eq(11, items.pItem.pToken1.pvalue);
assert(items.pItemsMore !is null);
ItemsMore * itemsmore = items.pItemsMore;
assert(itemsmore.pItem !is null);
assert(itemsmore.pItem.pItem !is null);
assert(itemsmore.pItem.pItem.pItem !is null);
assert(itemsmore.pItem.pItem.pItem.pToken1 !is null);
assert_eq(TOKEN_b, itemsmore.pItem.pItem.pItem.pToken1.token);
assert_eq(22, itemsmore.pItem.pItem.pItem.pToken1.pvalue);
assert(itemsmore.pItemsMore !is null);
itemsmore = itemsmore.pItemsMore;
assert(itemsmore.pItem !is null);
assert(itemsmore.pItem.pToken1 !is null);
assert_eq(TOKEN_b, itemsmore.pItem.pToken1.token);
assert_eq(22, itemsmore.pItem.pToken1.pvalue);
assert(itemsmore.pItemsMore is null);
input = "";
p_context_init(&context, input);
assert_eq(P_SUCCESS, p_parse(&context));
start = p_result(&context);
assert(start.pItems1 is null);
assert(start.pItems is null);
input = "2 1";
p_context_init(&context, input);
assert_eq(P_SUCCESS, p_parse(&context));
start = p_result(&context);
assert(start.pItems1 !is null);
assert(start.pItems1.pItem1 !is null);
assert(start.pItems1.pItem1.pDual1 !is null);
assert(start.pItems1.pItem1.pDual1.pTwo1 !is null);
assert(start.pItems1.pItem1.pDual1.pOne2 !is null);
assert(start.pItems1.pItem1.pDual1.pTwo2 is null);
assert(start.pItems1.pItem1.pDual1.pOne1 is null);
assert(start.pItems !is null);
assert(start.pItems.pItem !is null);
assert(start.pItems.pItem.pDual !is null);
assert(start.pItems.pItem.pDual.pTwo1 !is null);
assert(start.pItems.pItem.pDual.pOne2 !is null);
assert(start.pItems.pItem.pDual.pTwo2 is null);
assert(start.pItems.pItem.pDual.pOne1 is null);
}