MCPcopy Create free account
hub / github.com/argotorg/solidity / parseExpectations

Method parseExpectations

test/CommonSyntaxTest.cpp:234–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234std::vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(std::istream& _stream)
235{
236 static std::string const customExpectationsDelimiter("// ----");
237
238 std::vector<SyntaxTestError> expectations;
239 std::string line;
240 while (std::getline(_stream, line))
241 {
242 auto it = line.begin();
243
244 // Anything below the delimiter is left up to the derived class to process in a custom way.
245 // The delimiter is optional and identical to the one that starts error expectations in
246 // TestCaseReader::parseSourcesAndSettingsWithLineNumber().
247 if (boost::algorithm::starts_with(line, customExpectationsDelimiter))
248 break;
249
250 skipSlashes(it, line.end());
251 skipWhitespace(it, line.end());
252
253 if (it == line.end()) continue;
254
255 auto typeBegin = it;
256 while (it != line.end() && isalpha(*it, std::locale::classic()))
257 ++it;
258
259 std::string errorTypeStr(typeBegin, it);
260 std::optional<Error::Type> errorType = Error::parseErrorType(errorTypeStr);
261 if (!errorType.has_value())
262 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid error type: " + errorTypeStr));
263
264 skipWhitespace(it, line.end());
265
266 std::optional<ErrorId> errorId;
267 if (it != line.end() && util::isDigit(*it))
268 errorId = ErrorId{static_cast<unsigned long long>(parseUnsignedInteger(it, line.end()))};
269
270 expect(it, line.end(), ':');
271 skipWhitespace(it, line.end());
272
273 int locationStart = -1;
274 int locationEnd = -1;
275 std::string sourceName;
276
277 if (it != line.end() && *it == '(')
278 {
279 ++it;
280 if (it != line.end() && !util::isDigit(*it))
281 {
282 auto sourceNameStart = it;
283 while (it != line.end() && *it != ':')
284 ++it;
285 sourceName = std::string(sourceNameStart, it);
286 expect(it, line.end(), ':');
287 }
288 locationStart = parseUnsignedInteger(it, line.end());
289 expect(it, line.end(), '-');
290 locationEnd = parseUnsignedInteger(it, line.end());
291 expect(it, line.end(), ')');

Callers

nothing calls this directly

Calls 6

skipWhitespaceFunction · 0.85
isDigitFunction · 0.85
parseUnsignedIntegerFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected