diff options
Diffstat (limited to 'src/emu/netlist/plib/pparser.c')
-rw-r--r-- | src/emu/netlist/plib/pparser.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/emu/netlist/plib/pparser.c b/src/emu/netlist/plib/pparser.c index 95b9260c7cd..954b9048810 100644 --- a/src/emu/netlist/plib/pparser.c +++ b/src/emu/netlist/plib/pparser.c @@ -6,6 +6,7 @@ */ #include <cstdio> +#include <cstdarg> #include "pparser.h" @@ -96,6 +97,16 @@ pstring ptokenizer::get_identifier() return tok.str(); } +pstring ptokenizer::get_identifier_or_number() +{ + token_t tok = get_token(); + if (!(tok.is_type(IDENTIFIER) || tok.is_type(NUMBER))) + { + error("Error: expected an identifier, got <%s>\n", tok.str().cstr()); + } + return tok.str(); +} + double ptokenizer::get_number_double() { token_t tok = get_token(); @@ -256,6 +267,7 @@ ATTR_COLD void ptokenizer::error(const char *format, ...) ppreprocessor::ppreprocessor() { + m_expr_sep.add("!"); m_expr_sep.add("("); m_expr_sep.add(")"); m_expr_sep.add("+"); @@ -283,11 +295,20 @@ double ppreprocessor::expr(const pstring_list_t &sexpr, std::size_t &start, int if (tok == "(") { start++; - val = expr(sexpr, start, prio); + val = expr(sexpr, start, /*prio*/ 0); if (sexpr[start] != ")") error("parsing error!"); start++; } + else if (tok == "!") + { + start++; + val = expr(sexpr, start, 90); + if (val != 0) + val = 0; + else + val = 1; + } else { tok=sexpr[start]; @@ -442,7 +463,7 @@ pstring ppreprocessor::process(const pstring &contents) } } else - error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", i, line.cstr())); + error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", SIZET_PRINTF(i), line.cstr())); } else { |