void generate_sentence(char * element) {
	list_nodeT * curr_node, * production = NULL;

	production = get_non_terminal_random_production(element);
	
	if(production == NULL ) {
		printf("ERROR!");
		fprintf(stderr, "ERROR: No production found for the '%s' non terminal element.\nQuiting...\n", element);
		exit(-1);
	}

	curr_node = walk_list(production);

	while ( production != curr_node ) {
		char * token = curr_node->content;

		if (is_non_terminal(token)) {
			generate_sentence(token);
		}
		else {
			print_formatted(token);
		}
		curr_node = walk_list(curr_node);
	}
	
	return;
}
Example #2
0
    void CudaGPU::visit(const Nodecl::CudaKernelCall &n)
    {
        Nodecl::NodeclBase nodecl_function_call = n.get_function_call();
        Nodecl::NodeclBase kernel_config = n.get_kernel_config();

        Nodecl::FunctionCall function_call = nodecl_function_call.as<Nodecl::FunctionCall>();
        Nodecl::NodeclBase called_expr = function_call.get_called();
        Nodecl::NodeclBase function_args = function_call.get_arguments();

        walk(called_expr);

        *file << "<<<";
        walk_list(kernel_config.as<Nodecl::List>(),", ");
        *file << ">>>";

        *file << "(";
        if (!function_args.is_null())
        {
            walk_list(function_args.as<Nodecl::List>(), ", ");
        }
        *file << ")";
    }