diff options
author | 2019-03-26 11:13:37 +1100 | |
---|---|---|
committer | 2019-03-26 11:13:37 +1100 | |
commit | 97b67170277437131adf6ed4d60139c172529e4f (patch) | |
tree | 7a5cbf608f191075f1612b1af15832c206a3fe2d /src/lib/netlist/nl_parser.cpp | |
parent | b380514764cf857469bae61c11143a19f79a74c5 (diff) |
(nw) Clean up the mess on master
This effectively reverts b380514764cf857469bae61c11143a19f79a74c5 and
c24473ddff715ecec2e258a6eb38960cf8c8e98e, restoring the state at
598cd5227223c3b04ca31f0dbc1981256d9ea3ff.
Before pushing, please check that what you're about to push is sane.
Check your local commit log and ensure there isn't anything out-of-place
before pushing to mainline. When things like this happen, it wastes
everyone's time. I really don't need this in a week when real work⢠is
busting my balls and I'm behind where I want to be with preparing for
MAME release.
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index 4685a13c354..cecfbe862bf 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -6,9 +6,9 @@ */ #include "nl_parser.h" -#include "nl_factory.h" -#include "nl_errstr.h" #include "nl_base.h" +#include "nl_errstr.h" +#include "nl_factory.h" namespace netlist { @@ -24,13 +24,13 @@ void parser_t::verror(const pstring &msg, int line_num, const pstring &line) //throw error; } - bool parser_t::parse(const pstring &nlname) { - set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); - set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers - set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); - set_comment("/*", "*/", "//"); + 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(","); @@ -357,10 +357,10 @@ void parser_t::device(const pstring &dev_type) m_setup.register_dev(dev_type, devname); m_setup.log().debug("Parser: IC: {1}\n", devname); - for (pstring tp : paramlist) + for (const pstring &tp : paramlist) { require_token(m_tok_comma); - if (tp.startsWith("+")) + if (plib::startsWith(tp, "+")) { pstring output_name = get_identifier(); m_setup.log().debug("Link: {1} {2}\n", tp, output_name); @@ -395,18 +395,15 @@ void parser_t::device(const pstring &dev_type) // ---------------------------------------------------------------------------------------- -nl_double parser_t::eval_param(const token_t tok) +nl_double parser_t::eval_param(const token_t &tok) { - 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; - bool e; + static std::array<pstring, 6> macs = {"", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"}; + static std::array<nl_double, 6> facs = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12}; + std::size_t f=0; nl_double ret; - pstring val; - for (i=1; i<6;i++) - if (tok.str().equals(macs[i])) + for (std::size_t i=1; i<macs.size();i++) + if (tok.str() == macs[i]) f = i; if (f>0) { @@ -416,13 +413,13 @@ nl_double parser_t::eval_param(const token_t tok) } else { - val = tok.str(); - ret = val.as_double(&e); - if (e) - error(plib::pfmt("Parameter value <{1}> not double \n")(val)); + bool err; + ret = plib::pstonum_ne<nl_double>(tok.str(), err); + if (err) + error(plib::pfmt("Parameter value <{1}> not double \n")(tok.str())); } return ret * facs[f]; } -} +} // namespace netlist |