summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-01-20 22:17:58 +0100
committer couriersud <couriersud@gmx.org>2019-01-20 22:18:07 +0100
commit26420facff351d16d15a9ace7434aeaabccce9b5 (patch)
tree4ec07c0c9a831895bde1a24b631fbd99dbdb761f
parent46485eb727d2e7db32cda1fe44fdd252afc9cdfb (diff)
netlist: add comment processing to preprocessor. [couriersud]
Comments are now processed in the preprocessor. Previously directives in multiline comments were processed.
-rw-r--r--src/lib/netlist/plib/pparser.cpp65
-rw-r--r--src/lib/netlist/plib/pparser.h13
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp2
-rw-r--r--src/mame/audio/nl_kidniki.cpp2
4 files changed, 78 insertions, 4 deletions
diff --git a/src/lib/netlist/plib/pparser.cpp b/src/lib/netlist/plib/pparser.cpp
index f7b7c7bae36..8cfc2b20cec 100644
--- a/src/lib/netlist/plib/pparser.cpp
+++ b/src/lib/netlist/plib/pparser.cpp
@@ -274,6 +274,8 @@ ppreprocessor::ppreprocessor(std::vector<define_t> *defines)
, m_level(0)
, m_lineno(0)
, m_pos(0)
+, m_state(PROCESS)
+, m_comment(false)
{
m_expr_sep.push_back("!");
m_expr_sep.push_back("(");
@@ -400,8 +402,69 @@ static pstring catremainder(const std::vector<pstring> &elems, std::size_t start
return ret;
}
-pstring ppreprocessor::process_line(const pstring &line)
+pstring ppreprocessor::process_comments(pstring line)
{
+ bool in_string = false;
+
+ std::size_t e = line.size();
+ pstring ret = "";
+ for (std::size_t i=0; i < e; )
+ {
+ pstring c = plib::left(line, 1);
+ line = line.substr(1);
+ if (!m_comment)
+ {
+ if (c=="\"")
+ {
+ in_string = !in_string;
+ ret += c;
+ }
+ else if (in_string && c=="\\")
+ {
+ i++;
+ ret += (c + plib::left(line, 1));
+ line = line.substr(1);
+ }
+ else if (!in_string && c=="/" && plib::left(line,1) == "*")
+ m_comment = true;
+ else if (!in_string && c=="/" && plib::left(line,1) == "/")
+ break;
+ else
+ ret += c;
+ }
+ else
+ if (c=="*" && plib::left(line,1) == "/")
+ {
+ i++;
+ line = line.substr(1);
+ m_comment = false;
+ }
+ i++;
+ }
+ return ret;
+}
+
+pstring ppreprocessor::process_line(pstring line)
+{
+ bool line_cont = plib::right(line, 1) == "\\";
+ if (line_cont)
+ line = plib::left(line, line.size() - 1);
+
+ if (m_state == LINE_CONTINUATION)
+ m_line += line;
+ else
+ m_line = line;
+
+ if (line_cont)
+ {
+ m_state = LINE_CONTINUATION;
+ return "";
+ }
+ else
+ m_state = PROCESS;
+
+ line = process_comments(m_line);
+
pstring lt = plib::trim(plib::replace_all(line, pstring("\t"), pstring(" ")));
pstring ret;
// FIXME ... revise and extend macro handling
diff --git a/src/lib/netlist/plib/pparser.h b/src/lib/netlist/plib/pparser.h
index 36ecd02e017..1eeb92d797b 100644
--- a/src/lib/netlist/plib/pparser.h
+++ b/src/lib/netlist/plib/pparser.h
@@ -188,6 +188,8 @@ public:
, m_lineno(s.m_lineno)
, m_buf(s.m_buf)
, m_pos(s.m_pos)
+ , m_state(s.m_state)
+ , m_comment(s.m_comment)
{
}
@@ -204,7 +206,13 @@ protected:
private:
- pstring process_line(const pstring &line);
+ enum state_e
+ {
+ PROCESS,
+ LINE_CONTINUATION
+ };
+ pstring process_line(pstring line);
+ pstring process_comments(pstring line);
std::unordered_map<pstring, define_t> m_defines;
std::vector<pstring> m_expr_sep;
@@ -214,6 +222,9 @@ private:
int m_lineno;
pstring_t<pu8_traits> m_buf;
pos_type m_pos;
+ state_e m_state;
+ pstring m_line;
+ bool m_comment;
};
}
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index c578dedefbf..3421081b7ec 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -288,7 +288,7 @@ void NETLIB_NAME(solver)::post_start()
switch (net_count)
{
-#if 1
+#if 0
case 1:
if (use_specific)
ms = plib::palloc<matrix_solver_direct1_t>(state(), sname, &m_params);
diff --git a/src/mame/audio/nl_kidniki.cpp b/src/mame/audio/nl_kidniki.cpp
index a8bad7ace16..f430637868f 100644
--- a/src/mame/audio/nl_kidniki.cpp
+++ b/src/mame/audio/nl_kidniki.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Andrew Gardner, Couriersud
#include "netlist/devices/net_lib.h"
-#define USE_FRONTIERS 0
+#define USE_FRONTIERS 1
#define USE_FIXED_STV 1
/* ----------------------------------------------------------------------------