void Atom::show(std::ostream &out) const { out << " element:"<< get_element_table().get_name(get_element()); out << " type: "<< get_atom_type(); if (get_input_index() != -1) { out << " input index: " << get_input_index(); } if (core::XYZ::particle_is_instance(get_particle())) { out << " coords: " << core::XYZ(get_particle()); } }
static void gen_group(const ast *group, FILE *out){ int total_weight = 0; for(size_t i = 0; i < group->size; ++i){ const ast *option = group->children[i]; atom_type type = get_atom_type(option->children[0]); atom_quantifier quantifier = get_option_quantifier(option); total_weight += lgen_atom_weight[type][quantifier]; } int x = rand()%total_weight; for(size_t i = 0; i < group->size; ++i){ const ast *option = group->children[i]; atom_type type = get_atom_type(option->children[0]); atom_quantifier quantifier = get_option_quantifier(option); int weight = lgen_atom_weight[type][quantifier]; if(x < weight){ gen_option(option, out); break; } x -= weight; } }
static void gen_atom(const ast *atom, FILE *out){ const state *s; switch(get_atom_type(atom)){ case ATOM_STRING: fprintf(out, "%s", atom->children[0]->text); break; case ATOM_CHARSET: gen_charset(atom->children[0], out); break; case ATOM_SPECIAL: case ATOM_PARENS: case ATOM_RULE: s = (const state*)atom->children[0]->text; s->gen(s, out); break; } }