Beispiel #1
0
void MPpar::attach(char *pre, char *post)
{
	MPpar *t1;
	int	n1, n2;

	for (n2 = 1; n2 < num_nodes; n2++)
	{
#if 0
		if (nodes[n2-1]->type != NODE_TREE
		|| nodes[n2]->type != NODE_TREE)
			continue;
#endif

		if (strcmp(nodes[n2]->tag, post) == 0)
		{
			// printf("Searching for %s-%s attachment of node %d\n", pre, post, n2);

			// Search for the previous adjacent node
			// see if it is an NP (pre)

			search_right(n2 - 1, pre, t1, n1);

			if (t1)
			{
				transport(pre, t1, n1, n2);

				// Start over from the beginning now

				n2 = 0;
			}
		}
	}
}
Beispiel #2
0
void change_zero(struct InterCodes* start, Operand op){//change op into #0
	struct InterCodes* p = start;
	while(p != NULL){
		Operand temp = search_right(p, op);
		if(temp != NULL){
			temp->kind = CONSTANT;
			temp->u.value = 0;
		}
		p = p->next;
	}
}
Beispiel #3
0
int main(int argc, char const *argv[]) {
  assert(search_right("", "") == -1);
  assert(search_right("a", "a") == 0);
  assert(search_right("ab", "a") == 0);
  assert(search_right("aba", "a") == 2);
  assert(search_right("aabaa", "aa") == 3);
  assert(search_right("axbaxzzxa", "ax") == 3);

  return 0;
}