Ejemplo n.º 1
0
void finalize_syntax(struct syntax *syn, int saved_nr_errors)
{
	int i;

	if (syn->states.count == 0)
		error_msg("Empty syntax");

	for (i = 0; i < syn->states.count; i++) {
		struct state *s = syn->states.ptrs[i];
		if (!s->defined) {
			// this state has been referenced but not defined
			error_msg("No such state %s", s->name);
		}
	}
	for (i = 0; i < syn->string_lists.count; i++) {
		struct string_list *list = syn->string_lists.ptrs[i];
		if (!list->defined)
			error_msg("No such list %s", list->name);
	}

	if (syn->heredoc && !is_subsyntax(syn))
		error_msg("heredocend can be used only in subsyntaxes");

	if (find_any_syntax(syn->name))
		error_msg("Syntax %s already exists", syn->name);

	if (nr_errors != saved_nr_errors) {
		free_syntax(syn);
		return;
	}

	// unused states and lists cause warning only
	visit(syn->states.ptrs[0]);
	for (i = 0; i < syn->states.count; i++) {
		struct state *s = syn->states.ptrs[i];
		if (!s->visited && !s->copied)
			error_msg("State %s is unreachable", s->name);
	}
	for (i = 0; i < syn->string_lists.count; i++) {
		struct string_list *list = syn->string_lists.ptrs[i];
		if (!list->used)
			error_msg("List %s never used", list->name);
	}

	ptr_array_add(&syntaxes, syn);
}
Ejemplo n.º 2
0
void WINAPI Exit(void)
{
  free_syntax();
}