/* See LICENSE file for copyright and license details. */ #include "common.h" #ifndef TEST /** * Annotate every sentence that appear multiple times * with a unique index (counted from 0 up) * * @param this The sentence that shall be inspected * recursively for annotation * @return The number of annotated sentences */ size_t (libnormalform_set_indices_and_counts__)(LIBNORMALFORM_SENTENCE *this) { LIBNORMALFORM_SENTENCE *head = NULL, *a, *b; size_t count = 0; this->travel_count = 1; do { if (IS_BRANCH(this)) { a = LEFT(this); b = RIGHT(this); a->travel_count += 1; if (a->travel_count == 2) a->travel_index = count++; b->travel_count += 1; if (b->travel_count == 2) b->travel_index = count++; if (b->travel_count == 1) PUSH(&head, b); if (a->travel_count == 1) PUSH(&head, a); } } while (POP(&head, &this)); return count; } #else CONST int main(void) { return 0; /* indirectly tested */ } #endif