MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / Parser

Class Parser

app/src/DataModel/Importers/ProtoImporter.cpp:320–352  ·  view source on GitHub ↗

* @brief Recursive-descent parser for a small proto3 subset (messages, scalars, nested types). */

Source from the content-addressed store, hash-verified

318 * @brief Recursive-descent parser for a small proto3 subset (messages, scalars, nested types).
319 */
320class Parser {
321public:
322 Parser(const QString& src, QString& packageOut, QVector<DataModel::ProtoMessage>& outMessages);
323
324 bool parseFile(ParseError& err);
325
326private:
327 bool accept(Tok t);
328 bool expect(Tok t, const QString& what, ParseError& err);
329 void advance();
330 void skipToSemicolon();
331 void skipBlock();
332 void skipOptionList();
333
334 bool parseMessage(const QString& parentQualified,
335 DataModel::ProtoMessage& out,
336 ParseError& err,
337 int depth);
338 bool parseField(DataModel::ProtoMessage& msg, ParseError& err);
339 bool parseOneof(DataModel::ProtoMessage& msg, ParseError& err);
340 bool parseMap(DataModel::ProtoMessage& msg, ParseError& err);
341 bool parseEnumBody(ParseError& err);
342 bool parseFieldTag(int& tag, ParseError& err);
343 int tryParseMessageBodyKeyword(DataModel::ProtoMessage& out, ParseError& err, int depth);
344
345 static constexpr int kMaxMessageNestingDepth = 64;
346 static constexpr int kMaxProtoFieldTag = 536870911;
347
348 Lexer m_lexer;
349 Token m_cur;
350 QString& m_packageOut;
351 QVector<DataModel::ProtoMessage>& m_messages;
352};
353
354/**
355 * @brief Constructs the parser over a proto3 source buffer; primes the lookahead token.

Callers 4

pl_PL.tsFile · 0.85
it_IT.tsFile · 0.85
de_DE.tsFile · 0.85
ro_RO.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected