Skip to content

Instantly share code, notes, and snippets.

@jpcima
Created March 27, 2020 23:23
Show Gist options
  • Save jpcima/ac5babfefca5ce6d7086d93f7fef9121 to your computer and use it in GitHub Desktop.
Save jpcima/ac5babfefca5ce6d7086d93f7fef9121 to your computer and use it in GitHub Desktop.
diff --git a/src/sfizz/parser/Parser.cpp b/src/sfizz/parser/Parser.cpp
index 8007e40c..20ba42ca 100644
--- a/src/sfizz/parser/Parser.cpp
+++ b/src/sfizz/parser/Parser.cpp
@@ -236,20 +236,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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment