From 5a292aca3110cf70d9545024d9a1917b5b556d55 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 28 Mar 2020 00:26:37 +0100 Subject: [PATCH] End the value when hitting < too --- src/sfizz/parser/Parser.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/sfizz/parser/Parser.cpp b/src/sfizz/parser/Parser.cpp index db286465..13572cea 100644 --- a/src/sfizz/parser/Parser.cpp +++ b/src/sfizz/parser/Parser.cpp @@ -256,20 +256,25 @@ void Parser::processOpcode() std::string valueRaw; extractToEol(reader, &valueRaw); - // if another "=" character was hit, it means we read too far - size_t position = valueRaw.find('='); + // if a "=" or "<" character was hit, it means we read too far + size_t position = valueRaw.find_first_of("=<"); if (position != valueRaw.npos) { - while (position > 0 && isRawOpcodeNameChar(valueRaw[position - 1])) - --position; - while (position > 0 && isSpaceChar(valueRaw[position - 1])) - --position; + char hitChar = valueRaw[position]; + + // if it was "=", rewind before the opcode name and spaces preceding + if (hitChar == '=') { + while (position > 0 && isRawOpcodeNameChar(valueRaw[position - 1])) + --position; + while (position > 0 && isSpaceChar(valueRaw[position - 1])) + --position; + } absl::string_view excess(&valueRaw[position], valueRaw.size() - position); reader.putBackChars(excess); valueRaw.resize(position); // ensure that we are landing back next to a space char - if (!reader.hasOneOfChars(" \t\r\n")) { + if (hitChar == '=' && !reader.hasOneOfChars(" \t\r\n")) { SourceLocation end = reader.location(); emitError({ valueStart, end }, "Unexpected `=` in opcode value."); recover();