diff options
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index cecfbe862bf..4685a13c354 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_base.h" -#include "nl_errstr.h" #include "nl_factory.h" +#include "nl_errstr.h" +#include "nl_base.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) { - 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("/*", "*/", "//"); + 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("/*", "*/", "//"); 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 (const pstring &tp : paramlist) + for (pstring tp : paramlist) { require_token(m_tok_comma); - if (plib::startsWith(tp, "+")) + if (tp.startsWith("+")) { pstring output_name = get_identifier(); m_setup.log().debug("Link: {1} {2}\n", tp, output_name); @@ -395,15 +395,18 @@ 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 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; + 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; nl_double ret; + pstring val; - for (std::size_t i=1; i<macs.size();i++) - if (tok.str() == macs[i]) + for (i=1; i<6;i++) + if (tok.str().equals(macs[i])) f = i; if (f>0) { @@ -413,13 +416,13 @@ nl_double parser_t::eval_param(const token_t &tok) } else { - bool err; - ret = plib::pstonum_ne<nl_double>(tok.str(), err); - if (err) - error(plib::pfmt("Parameter value <{1}> not double \n")(tok.str())); + val = tok.str(); + ret = val.as_double(&e); + if (e) + error(plib::pfmt("Parameter value <{1}> not double \n")(val)); } return ret * facs[f]; } -} // namespace netlist +} |