diff options
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index d1156117f8e..7f4d7bd4e7e 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -236,10 +236,12 @@ void parser_t::frontier() // don't do much pstring attachat = get_identifier(); require_token(m_tok_comma); - nl_fptype r_IN = eval_param(get_token()); - require_token(m_tok_comma); - nl_fptype r_OUT = eval_param(get_token()); - require_token(m_tok_paren_right); + auto tok = get_token(); + nl_fptype r_IN = eval_param(tok); + require_token(tok, m_tok_comma); + tok = get_token(); + nl_fptype r_OUT = eval_param(tok); + require_token(tok, m_tok_paren_right); m_setup.register_frontier(attachat, r_IN, r_OUT); } @@ -335,14 +337,15 @@ void parser_t::netdev_param() { m_setup.log().debug("Parser: Param: {1} {2}\n", param, tok.str()); m_setup.register_param(param, tok.str()); + require_token(m_tok_paren_right); } else { nl_fptype val = eval_param(tok); m_setup.log().debug("Parser: Param: {1} {2}\n", param, val); m_setup.register_param(param, val); + require_token(tok, m_tok_paren_right); } - require_token(m_tok_paren_right); } void parser_t::netdev_hint() @@ -370,7 +373,10 @@ void parser_t::device(const pstring &dev_type) { tok = get_token(); if (tok.is_type(token_type::IDENTIFIER) || tok.is_type(token_type::STRING)) + { params.push_back(tok.str()); + tok = get_token(); + } else { // FIXME: Do we really need this? @@ -381,7 +387,6 @@ void parser_t::device(const pstring &dev_type) else params.push_back(plib::pfmt("{1}")(static_cast<long>(value))); } - tok = get_token(); } require_token(tok, m_tok_paren_right); @@ -393,9 +398,32 @@ void parser_t::device(const pstring &dev_type) // private // ---------------------------------------------------------------------------------------- -nl_fptype parser_t::eval_param(const token_t &tok) +nl_fptype parser_t::eval_param(token_t &tok) { +#if USE_EVAL + int pc(0); + pstring ret; + while (!tok.is(m_tok_comma)) + { + if (tok.is(m_tok_paren_left)) + pc++; + else if (tok.is(m_tok_paren_right)) + { + if (pc<=0) + break; + pc--; + } + ret += tok.str(); + tok = get_token(); + } + // FIXME: Not necessary here, should be done if parameter is read by devices + plib::pfunction<nl_fptype> func; + func.compile_infix(ret, {}); + return func.evaluate(); + +#else static std::array<pstring, 7> macs = {"", "RES_R", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"}; + static std::array<nl_fptype, 7> facs = { nlconst::magic(1.0), nlconst::magic(1.0), @@ -424,8 +452,9 @@ nl_fptype parser_t::eval_param(const token_t &tok) if (err) error(MF_PARAM_NOT_FP_1(tok.str())); } + tok = get_token(); return ret * facs[f]; - +#endif } } // namespace netlist |