* @brief Parses a `oneof Name { fields }` block; fields are appended as plain fields. */
| 444 | * @brief Parses a `oneof Name { fields }` block; fields are appended as plain fields. |
| 445 | */ |
| 446 | bool Parser::parseOneof(DataModel::ProtoMessage& msg, ParseError& err) |
| 447 | { |
| 448 | if (m_cur.type != Tok::Ident) { |
| 449 | err = {m_cur.line, QObject::tr("Expected oneof name")}; |
| 450 | return false; |
| 451 | } |
| 452 | advance(); |
| 453 | if (!expect(Tok::LBrace, QStringLiteral("'{'"), err)) |
| 454 | return false; |
| 455 | |
| 456 | while (m_cur.type != Tok::Eof && m_cur.type != Tok::RBrace) { |
| 457 | if (m_cur.type == Tok::Ident && m_cur.text == QLatin1String("option")) { |
| 458 | skipToSemicolon(); |
| 459 | continue; |
| 460 | } |
| 461 | if (!parseField(msg, err)) |
| 462 | return false; |
| 463 | } |
| 464 | return expect(Tok::RBrace, QStringLiteral("'}'"), err); |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * @brief Reads the current IntLit token as a protobuf field tag and validates its range. |