diff options
author | 2020-01-27 21:47:41 +0100 | |
---|---|---|
committer | 2020-01-27 21:47:41 +0100 | |
commit | f7d8a10da53e07747ab4f11d5c7b4827869e5763 (patch) | |
tree | 1ae8c2b3a06a6abd253814bd159cb151dd6cc20a /src/lib/netlist/plib/ppreprocessor.cpp | |
parent | 8c2bb6236774977e848c62fad35eb665a6d8e58b (diff) |
netlist: Code maintenance. (nw)
- Fixed some clang lint warnings
- Removed dead code
- Experimental parser code to allow calculations in parameter value.
This already works for compiled netlists. These changes are
currently disabled. Updated pong netlist (and CRC/SHA) to work
with this new code.
Diffstat (limited to 'src/lib/netlist/plib/ppreprocessor.cpp')
-rw-r--r-- | src/lib/netlist/plib/ppreprocessor.cpp | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/lib/netlist/plib/ppreprocessor.cpp b/src/lib/netlist/plib/ppreprocessor.cpp index f98a57cb921..e2058a5b5ad 100644 --- a/src/lib/netlist/plib/ppreprocessor.cpp +++ b/src/lib/netlist/plib/ppreprocessor.cpp @@ -56,7 +56,7 @@ namespace plib { pstring e = plib::pfmt("{1}:{2}:0: error: {3}\n") (m_stack.back().m_name, m_stack.back().m_lineno, err); m_stack.pop_back(); - while (m_stack.size() > 0) + while (!m_stack.empty()) { if (m_stack.size() == 1) trail = trail_first; @@ -236,38 +236,51 @@ namespace plib { tmpret.push_back(s); } else - if (!remove_ws || (tmp[pi] != " " && tmp[pi] != "\t")) - tmpret.push_back(tmp[pi]); + { + pstring tok=tmp[pi]; + if (tok.size() >= 2 && pi < tmp.size() - 2 ) + { + auto sc=tok.substr(0,1); + auto ec=tok.substr(tok.size()-1, 1); + if ((sc == "." || (sc>="0" && sc<="9")) && (ec=="e" || ec=="E")) + { + // looks like an incomplete float due splitting by - or + + tok = tok + tmp[pi+1] + tmp[pi+2]; + pi += 2; + } + } + if (!remove_ws || (tok != " " && tok != "\t")) + tmpret.push_back(tok); + } pi++; } + if (!concat) return tmpret; - else + + // FIXME: error if concat at beginning or end + string_list ret; + pi = 0; + while (pi<tmpret.size()) { - // FIXME: error if concat at beginning or end - string_list ret; - pi = 0; - while (pi<tmpret.size()) + if (tmpret[pi] == "##") { - if (tmpret[pi] == "##") - { - while (ret.back() == " " || ret.back() == "\t") - ret.pop_back(); - pstring cc = ret.back(); + while (ret.back() == " " || ret.back() == "\t") ret.pop_back(); - pi++; - while (pi < tmpret.size() && (tmpret[pi] == " " || tmpret[pi] == "\t")) - pi++; - if (pi == tmpret.size()) - error("## found at end of sequence"); - ret.push_back(cc + tmpret[pi]); - } - else - ret.push_back(tmpret[pi]); + pstring cc = ret.back(); + ret.pop_back(); pi++; + while (pi < tmpret.size() && (tmpret[pi] == " " || tmpret[pi] == "\t")) + pi++; + if (pi == tmpret.size()) + error("## found at end of sequence"); + ret.push_back(cc + tmpret[pi]); } - return ret; + else + ret.push_back(tmpret[pi]); + pi++; } + return ret; } bool ppreprocessor::is_valid_token(const pstring &str) |