Skip to content

Commit 7b8fa09

Browse files
🎨 pre-commit fixes
1 parent 47edfc0 commit 7b8fa09

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

‎src/common/parsing/CodePreprocessing.cpp‎

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,40 +111,35 @@ void validateTargets(const std::string& code, size_t instructionStart,
111111
continue;
112112
}
113113
const auto close = target.find(']', open + 1);
114-
if (open == 0 || close == std::string::npos ||
115-
close != target.size() - 1) {
116-
throw ParsingError(
117-
formatParseError(code, instructionStart,
118-
"Invalid target qubit " + target + context + ".",
119-
target));
114+
if (open == 0 || close == std::string::npos || close != target.size() - 1) {
115+
throw ParsingError(formatParseError(
116+
code, instructionStart,
117+
"Invalid target qubit " + target + context + ".", target));
120118
}
121119
const auto registerName = target.substr(0, open);
122120
const auto indexText = target.substr(open + 1, close - open - 1);
123121
if (!isDigits(indexText)) {
124-
throw ParsingError(
125-
formatParseError(code, instructionStart,
126-
"Invalid target qubit " + target + context + ".",
127-
target));
122+
throw ParsingError(formatParseError(
123+
code, instructionStart,
124+
"Invalid target qubit " + target + context + ".", target));
128125
}
129126
size_t registerIndex = 0;
130127
try {
131128
registerIndex = std::stoul(indexText);
132129
} catch (const std::exception&) {
133-
throw ParsingError(
134-
formatParseError(code, instructionStart,
135-
"Invalid target qubit " + target + context + ".",
136-
target));
130+
throw ParsingError(formatParseError(
131+
code, instructionStart,
132+
"Invalid target qubit " + target + context + ".", target));
137133
}
138134
if (std::ranges::find(shadowedRegisters, registerName) !=
139135
shadowedRegisters.end()) {
140136
continue;
141137
}
142138
const auto found = definedRegisters.find(registerName);
143139
if (found == definedRegisters.end() || found->second <= registerIndex) {
144-
throw ParsingError(
145-
formatParseError(code, instructionStart,
146-
"Invalid target qubit " + target + context + ".",
147-
target));
140+
throw ParsingError(formatParseError(
141+
code, instructionStart,
142+
"Invalid target qubit " + target + context + ".", target));
148143
}
149144
}
150145
}
@@ -448,8 +443,7 @@ preprocessCode(const std::string& code, size_t startIndex,
448443
auto isAssert = isAssertion(line);
449444
auto blockPos = line.find("$__block");
450445

451-
const auto leadingPos =
452-
blocksRemoved.find_first_not_of(" \t\r\n", pos);
446+
const auto leadingPos = blocksRemoved.find_first_not_of(" \t\r\n", pos);
453447
const size_t trueStart =
454448
((leadingPos != std::string::npos && leadingPos < end) ? leadingPos
455449
: pos) +
@@ -481,17 +475,17 @@ preprocessCode(const std::string& code, size_t startIndex,
481475
const auto& name = parts[0];
482476
const auto sizeText = parts.size() > 1 ? parts[1] : "";
483477
if (name.empty() || !isDigits(sizeText)) {
484-
throw ParsingError(formatParseError(
485-
code, trueStart,
486-
"Invalid register declaration " + trimmedLine + "."));
478+
throw ParsingError(formatParseError(code, trueStart,
479+
"Invalid register declaration " +
480+
trimmedLine + "."));
487481
}
488482
size_t size = 0;
489483
try {
490484
size = std::stoul(sizeText);
491485
} catch (const std::exception&) {
492-
throw ParsingError(formatParseError(
493-
code, trueStart,
494-
"Invalid register declaration " + trimmedLine + "."));
486+
throw ParsingError(formatParseError(code, trueStart,
487+
"Invalid register declaration " +
488+
trimmedLine + "."));
495489
}
496490
definedRegisters.insert({name, size});
497491
}

0 commit comments

Comments
 (0)