int recover_params(sq* model, vect* list, int no) { double _kx = 0, _ky = 0, _bk = 0.0000010, _ba = 0, _asq1 = 0, _asq2 = 0; if (State::lookup->on && State::lookup->isSet) { // Reset SQ params to those from lookup model->a1 = State::lookup->a; model->a2 = State::lookup->b; model->a3 = State::lookup->c; model->e1 = State::lookup->e1; model->e2 = State::lookup->e2; return recover_search(list, no, &model->a1, &model->a2, &model->a3, &model->e1, &model->e2, &model->px, &model->py, &model->pz, &model->phi, &model->theta, &model->psi, &_kx, &_ky, &_bk, &_ba, &_asq1, &_asq2, RECOVER_SQ); } return recover2(list, no, &model->a1, &model->a2, &model->a3, &model->e1, &model->e2, &model->px, &model->py, &model->pz, &model->phi, &model->theta, &model->psi, &_kx, &_ky, &_bk, &_ba, &_asq1, &_asq2, RECOVER_SQ); // return recover(list, no, // &model->a1, &model->a2, &model->a3, &model->e1, &model->e2, // &model->px, &model->py, &model->pz, &model->phi, &model->theta, &model->psi); }
static void parse_method(fb_parser_t *P, fb_member_t *fld) { fb_token_t *t; if (!(t = match(P, LEX_TOK_ID, "method expected identifier"))) { goto fail; } fld->symbol.ident = t; if (!match(P, '(', "method expected '(' after identifier")) { goto fail; } parse_type(P, &fld->req_type); if (!match(P, ')', "method expected ')' after request type")) { goto fail; } if (!match(P, ':', "method expected ':' before mandatory response type")) { goto fail; } parse_type(P, &fld->type); if ((t = optional(P, '='))) { error_tok(P, t, "method does not accept an initializer"); goto fail; } fld->metadata = parse_metadata(P); advance(P, ';', "method must be terminated with ';'", 0); return; fail: recover2(P, ';', 1, '}', 0); }
static void parse_field(fb_parser_t *P, fb_member_t *fld) { fb_token_t *t; if (!(t = match(P, LEX_TOK_ID, "field expected identifier"))) { goto fail; } fld->symbol.ident = t; if (!match(P, ':', "field expected ':' before mandatory type")) { goto fail; } parse_type(P, &fld->type); if (optional(P, '=')) { /* * Because types can be named references, we do not check the * default assignment before the schema is fully parsed. * We allow the initializer to be a name in case it is an enum * name. */ parse_value(P, &fld->value, allow_id_value, "initializer must be of scalar type"); } fld->metadata = parse_metadata(P); advance(P, ';', "field must be terminated with ';'", 0); return; fail: recover2(P, ';', 1, '}', 0); }
/* `union` must already be matched. */ static void parse_union_decl(fb_parser_t *P, fb_compound_type_t *ct) { fb_token_t *t0; fb_member_t *member; fb_ref_t *ref; if (!(ct->symbol.ident = match(P, LEX_TOK_ID, "union declaration expected identifier"))) { goto fail; } ct->metadata = parse_metadata(P); if (!((t0 = match(P, '{', "union declaration expected '{'")))) { goto fail; } for (;;) { if (P->token->id != LEX_TOK_ID) { error_tok(P, P->token, "union expects an identifier"); goto fail; } if (P->failed >= FLATCC_MAX_ERRORS) { goto fail; } member = fb_add_member(P, &ct->members); parse_ref(P, &ref); member->type.ref = ref; member->type.type = vt_type_ref; while (ref->link) { ref = ref->link; } /* The union member is the unqualified reference. */ member->symbol.ident = ref->ident; if (optional(P, '=')) { parse_value(P, &member->value, 0, "integral constant expected"); /* Leave detailed type (e.g. no floats) and range checking to a later stage. */ } if (!optional(P, ',') || P->token->id == '}') { break; } P->doc = 0; } advance(P, '}', "union missing closing '}' to match", t0); revert_symbols(&ct->members); /* Add implicit `NONE` member first in the list. */ member = fb_add_member(P, &ct->members); member->symbol.ident = &P->t_none; return; fail: recover2(P, ';', 1, '}', 0); }