diff options
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index 6dee211ce56..db7ced8fae0 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -7,7 +7,7 @@ #include "nl_parser.h" #include "nl_factory.h" -#include "devices/nld_truthtable.h" +#include "nl_errstr.h" namespace netlist { @@ -28,13 +28,7 @@ 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_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); set_comment("/*", "*/", "//"); m_tok_param_left = register_token("("); m_tok_param_right = register_token(")"); @@ -64,18 +58,16 @@ bool parser_t::parse(const pstring nlname) 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"); + error (MF_0_UNEXPECTED_NETLIST_END); else { in_nl = false; @@ -85,7 +77,7 @@ bool parser_t::parse(const pstring nlname) else if (token.is(m_tok_NETLIST_START)) { if (in_nl) - error("Unexpected NETLIST_START"); + error (MF_0_UNEXPECTED_NETLIST_START); require_token(m_tok_param_left); token_t name = get_token(); require_token(m_tok_param_right); @@ -99,7 +91,7 @@ bool parser_t::parse(const pstring nlname) } } -void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname) +void parser_t::parse_netlist(const pstring &nlname) { while (true) { @@ -132,10 +124,10 @@ void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname) else if (token.is(m_tok_LOCAL_SOURCE)) net_local_source(); else if (token.is(m_tok_TRUTHTABLE_START)) - net_truthtable_start(); + net_truthtable_start(nlname); else if (token.is(m_tok_LOCAL_LIB_ENTRY)) { - m_setup.register_lib_entry(get_identifier()); + m_setup.register_lib_entry(get_identifier(), "parser: " + nlname); require_token(m_tok_param_right); } else if (token.is(m_tok_NETLIST_END)) @@ -148,7 +140,7 @@ void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname) } } -void parser_t::net_truthtable_start() +void parser_t::net_truthtable_start(const pstring &nlname) { pstring name = get_identifier(); require_token(m_tok_comma); @@ -194,7 +186,7 @@ void parser_t::net_truthtable_start() require_token(token, m_tok_TRUTHTABLE_END); require_token(m_tok_param_left); require_token(m_tok_param_right); - netlist::devices::tt_factory_create(m_setup, desc); + m_setup.tt_factory_create(desc, nlname); return; } } @@ -300,7 +292,7 @@ void parser_t::net_c() void parser_t::dippins() { - plib::pstring_vector_t pins; + std::vector<pstring> pins; pins.push_back(get_identifier()); require_token(m_tok_comma); @@ -357,7 +349,7 @@ void parser_t::netdev_hint() void parser_t::device(const pstring &dev_type) { factory::element_t *f = m_setup.factory().factory_by_name(dev_type); - auto paramlist = plib::pstring_vector_t(f->param_desc(), ","); + auto paramlist = plib::psplit(f->param_desc(), ","); pstring devname = get_identifier(); @@ -404,7 +396,7 @@ void parser_t::device(const pstring &dev_type) nl_double parser_t::eval_param(const token_t tok) { - static const char *macs[6] = {"", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"}; + static pstring macs[6] = {"", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"}; static nl_double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12}; int i; int f=0; @@ -415,7 +407,6 @@ nl_double parser_t::eval_param(const token_t tok) for (i=1; i<6;i++) if (tok.str().equals(macs[i])) f = i; -#if 1 if (f>0) { require_token(m_tok_param_left); @@ -431,22 +422,6 @@ nl_double parser_t::eval_param(const token_t tok) } return ret * facs[f]; -#else - if (f>0) - { - require_token(m_tok_param_left); - val = get_identifier(); - } - else - val = tok.str(); - - ret = val.as_double(&e); - - if (e) - fatal("Error with parameter ...\n"); - if (f>0) - require_token(m_tok_param_right); - return ret * facs[f]; -#endif } + } |