End the value when hitting < too
This commit is contained in:
parent
847af7b731
commit
5a292aca31
1 changed files with 12 additions and 7 deletions
|
|
@ -256,20 +256,25 @@ void Parser::processOpcode()
|
||||||
std::string valueRaw;
|
std::string valueRaw;
|
||||||
extractToEol(reader, &valueRaw);
|
extractToEol(reader, &valueRaw);
|
||||||
|
|
||||||
// if another "=" character was hit, it means we read too far
|
// if a "=" or "<" character was hit, it means we read too far
|
||||||
size_t position = valueRaw.find('=');
|
size_t position = valueRaw.find_first_of("=<");
|
||||||
if (position != valueRaw.npos) {
|
if (position != valueRaw.npos) {
|
||||||
while (position > 0 && isRawOpcodeNameChar(valueRaw[position - 1]))
|
char hitChar = valueRaw[position];
|
||||||
--position;
|
|
||||||
while (position > 0 && isSpaceChar(valueRaw[position - 1]))
|
// if it was "=", rewind before the opcode name and spaces preceding
|
||||||
--position;
|
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);
|
absl::string_view excess(&valueRaw[position], valueRaw.size() - position);
|
||||||
reader.putBackChars(excess);
|
reader.putBackChars(excess);
|
||||||
valueRaw.resize(position);
|
valueRaw.resize(position);
|
||||||
|
|
||||||
// ensure that we are landing back next to a space char
|
// 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();
|
SourceLocation end = reader.location();
|
||||||
emitError({ valueStart, end }, "Unexpected `=` in opcode value.");
|
emitError({ valueStart, end }, "Unexpected `=` in opcode value.");
|
||||||
recover();
|
recover();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue