void netlist_parser::netdev_netlist_start() { // don't do much token_t name = get_token(); require_token(m_tok_param_right); }
bool parser_t::parse(const pstring nlname) { set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers char ws[5]; ws[0] = ' '; ws[1] = 9; ws[2] = 10; ws[3] = 13; ws[4] = 0; set_whitespace(ws); set_comment("/*", "*/", "//"); m_tok_param_left = register_token("("); m_tok_param_right = register_token(")"); m_tok_comma = register_token(","); m_tok_ALIAS = register_token("ALIAS"); m_tok_DIPPINS = register_token("DIPPINS"); m_tok_NET_C = register_token("NET_C"); m_tok_FRONTIER = register_token("OPTIMIZE_FRONTIER"); m_tok_PARAM = register_token("PARAM"); m_tok_NET_MODEL = register_token("NET_MODEL"); m_tok_INCLUDE = register_token("INCLUDE"); m_tok_LOCAL_SOURCE = register_token("LOCAL_SOURCE"); m_tok_LOCAL_LIB_ENTRY = register_token("LOCAL_LIB_ENTRY"); m_tok_SUBMODEL = register_token("SUBMODEL"); m_tok_NETLIST_START = register_token("NETLIST_START"); m_tok_NETLIST_END = register_token("NETLIST_END"); m_tok_TRUTHTABLE_START = register_token("TRUTHTABLE_START"); m_tok_TRUTHTABLE_END = register_token("TRUTHTABLE_END"); m_tok_TT_HEAD = register_token("TT_HEAD"); m_tok_TT_LINE = register_token("TT_LINE"); m_tok_TT_FAMILY = register_token("TT_FAMILY"); bool in_nl = false; while (true) { token_t token = get_token(); if (token.is_type(ENDOFFILE)) { return false; //error("EOF while searching for <{1}>", nlname); } if (token.is(m_tok_NETLIST_END)) { require_token(m_tok_param_left); if (!in_nl) error("Unexpected NETLIST_END"); else { in_nl = false; } require_token(m_tok_param_right); } else if (token.is(m_tok_NETLIST_START)) { if (in_nl) error("Unexpected NETLIST_START"); require_token(m_tok_param_left); token_t name = get_token(); require_token(m_tok_param_right); if (name.str() == nlname || nlname == "") { parse_netlist(name.str()); return true; } else in_nl = true; } } }
void parser_t::device(const pstring &dev_type) { if (m_setup.is_library_item(dev_type)) { pstring devname = get_identifier(); m_setup.namespace_push(devname); m_setup.include(dev_type); m_setup.namespace_pop(); require_token(m_tok_param_right); } else { base_factory_t *f = m_setup.factory().factory_by_name(dev_type); device_t *dev; pstring_list_t termlist = f->term_param_list(); pstring_list_t def_params = f->def_params(); std::size_t cnt; pstring devname = get_identifier(); dev = f->Create(); m_setup.register_dev(dev, devname); m_setup.log().debug("Parser: IC: {1}\n", devname); cnt = 0; while (cnt < def_params.size()) { pstring paramfq = devname + "." + def_params[cnt]; m_setup.log().debug("Defparam: {1}\n", paramfq); require_token(m_tok_comma); token_t tok = get_token(); if (tok.is_type(STRING)) { m_setup.register_param(paramfq, tok.str()); } else { nl_double val = eval_param(tok); m_setup.register_param(paramfq, val); } cnt++; } token_t tok = get_token(); cnt = 0; while (tok.is(m_tok_comma) && cnt < termlist.size()) { pstring output_name = get_identifier(); m_setup.register_link(devname + "." + termlist[cnt], output_name); cnt++; tok = get_token(); } if (cnt != termlist.size()) m_setup.log().fatal("netlist: input count mismatch for {1} - expected {2} found {3}\n", devname, termlist.size(), cnt); require_token(tok, m_tok_param_right); } }
void parser_t::net_truthtable_start() { pstring name = get_identifier(); require_token(m_tok_comma); unsigned ni = get_number_long(); require_token(m_tok_comma); unsigned no = get_number_long(); require_token(m_tok_comma); unsigned hs = get_number_long(); require_token(m_tok_comma); pstring def_param = get_string(); require_token(m_tok_param_right); netlist::devices::netlist_base_factory_truthtable_t *ttd = netlist::devices::nl_tt_factory_create(ni, no, hs, name, name, "+" + def_param); while (true) { token_t token = get_token(); if (token.is(m_tok_TT_HEAD)) { require_token(m_tok_param_left); ttd->m_desc.add(get_string()); require_token(m_tok_param_right); } else if (token.is(m_tok_TT_LINE)) { require_token(m_tok_param_left); ttd->m_desc.add(get_string()); require_token(m_tok_param_right); } else if (token.is(m_tok_TT_FAMILY)) { require_token(m_tok_param_left); ttd->m_family = m_setup.family_from_model(get_string()); require_token(m_tok_param_right); } else { require_token(token, m_tok_TRUTHTABLE_END); require_token(m_tok_param_left); require_token(m_tok_param_right); m_setup.factory().register_device(ttd); return; } } }
void parser_t::netdev_netlist_end() { // don't do much require_token(m_tok_param_right); }
bool netlist_parser::parse(const char *buf, const pstring nlname) { m_buf = buf; reset(buf); set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); set_number_chars("01234567890eE-."); //FIXME: processing of numbers char ws[5]; ws[0] = ' '; ws[1] = 9; ws[2] = 10; ws[3] = 13; ws[4] = 0; set_whitespace(ws); set_comment("/*", "*/", "//"); m_tok_param_left = register_token("("); m_tok_param_right = register_token(")"); m_tok_comma = register_token(","); m_tok_ALIAS = register_token("ALIAS"); m_tok_NET_C = register_token("NET_C"); m_tok_PARAM = register_token("PARAM"); m_tok_NET_MODEL = register_token("NET_MODEL"); m_tok_INCLUDE = register_token("INCLUDE"); m_tok_SUBMODEL = register_token("SUBMODEL"); m_tok_NETLIST_START = register_token("NETLIST_START"); m_tok_NETLIST_END = register_token("NETLIST_END"); bool in_nl = false; while (true) { token_t token = get_token(); if (token.is_type(ENDOFFILE)) { return false; //error("EOF while searching for <%s>", nlname.cstr()); } if (token.is(m_tok_NETLIST_END)) { require_token(m_tok_param_left); if (!in_nl) error("Unexpected NETLIST_END"); else { in_nl = false; } require_token(m_tok_param_right); } else if (token.is(m_tok_NETLIST_START)) { if (in_nl) error("Unexpected NETLIST_START"); require_token(m_tok_param_left); token_t name = get_token(); require_token(m_tok_param_right); if (name.str() == nlname || nlname == "") { parse_netlist(name.str()); return true; } else in_nl = true; } } }
void ptokenizer::require_token(const token_id_t &token_num) { require_token(get_token(), token_num); }
// translation_unit = interaction_list . bool adam_test_parser::parse() { is_interaction_list(); require_token(eof_k); return all_checks_passed_m; }
bool parser_t::parse(const pstring &nlname) { this->identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-") .number_chars(".0123456789", "0123456789eE-.") //FIXME: processing of numbers //set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); .whitespace(pstring("") + ' ' + static_cast<char>(9) + static_cast<char>(10) + static_cast<char>(13)) .comment("/*", "*/", "//"); m_tok_param_left = register_token("("); m_tok_param_right = register_token(")"); m_tok_comma = register_token(","); m_tok_ALIAS = register_token("ALIAS"); m_tok_DIPPINS = register_token("DIPPINS"); m_tok_NET_C = register_token("NET_C"); m_tok_FRONTIER = register_token("OPTIMIZE_FRONTIER"); m_tok_PARAM = register_token("PARAM"); m_tok_HINT = register_token("HINT"); m_tok_NET_MODEL = register_token("NET_MODEL"); m_tok_INCLUDE = register_token("INCLUDE"); m_tok_LOCAL_SOURCE = register_token("LOCAL_SOURCE"); m_tok_LOCAL_LIB_ENTRY = register_token("LOCAL_LIB_ENTRY"); m_tok_SUBMODEL = register_token("SUBMODEL"); m_tok_NETLIST_START = register_token("NETLIST_START"); m_tok_NETLIST_END = register_token("NETLIST_END"); m_tok_TRUTHTABLE_START = register_token("TRUTHTABLE_START"); m_tok_TRUTHTABLE_END = register_token("TRUTHTABLE_END"); m_tok_TT_HEAD = register_token("TT_HEAD"); m_tok_TT_LINE = register_token("TT_LINE"); m_tok_TT_FAMILY = register_token("TT_FAMILY"); bool in_nl = false; while (true) { token_t token = get_token(); if (token.is_type(ENDOFFILE)) { return false; } if (token.is(m_tok_NETLIST_END)) { require_token(m_tok_param_left); if (!in_nl) error (MF_0_UNEXPECTED_NETLIST_END); else { in_nl = false; } require_token(m_tok_param_right); } else if (token.is(m_tok_NETLIST_START)) { if (in_nl) error (MF_0_UNEXPECTED_NETLIST_START); require_token(m_tok_param_left); token_t name = get_token(); require_token(m_tok_param_right); if (name.str() == nlname || nlname == "") { parse_netlist(name.str()); return true; } else in_nl = true; } } }
void parser_t::net_truthtable_start(const pstring &nlname) { pstring name = get_identifier(); require_token(m_tok_comma); long ni = get_number_long(); require_token(m_tok_comma); long no = get_number_long(); require_token(m_tok_comma); pstring def_param = get_string(); require_token(m_tok_param_right); netlist::tt_desc desc; desc.classname = name; desc.name = name; desc.ni = static_cast<unsigned long>(ni); desc.no = static_cast<unsigned long>(no); desc.def_param = "+" + def_param; desc.family = ""; while (true) { token_t token = get_token(); if (token.is(m_tok_TT_HEAD)) { require_token(m_tok_param_left); desc.desc.push_back(get_string()); require_token(m_tok_param_right); } else if (token.is(m_tok_TT_LINE)) { require_token(m_tok_param_left); desc.desc.push_back(get_string()); require_token(m_tok_param_right); } else if (token.is(m_tok_TT_FAMILY)) { require_token(m_tok_param_left); desc.family = get_string(); require_token(m_tok_param_right); } else { require_token(token, m_tok_TRUTHTABLE_END); require_token(m_tok_param_left); require_token(m_tok_param_right); m_setup.tt_factory_create(desc, nlname); return; } } }
// end_statement = ";" [trail_comment]. void adam_parser::require_end_statement(std::string& brief) { require_token(semicolon_k); (void)is_trail_comment(brief); }
void adam_parser::parse() { name_t name; while (is_sheet_specifier(name)) ; require_token(eof_k); }