From 32a29ce37767ec75b50067838936f8c2efcf54e7 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 26 Sep 2025 08:23:18 +0000 Subject: [PATCH 1/2] [protobuf] Fix blockLit to allow trailing comma Apparently the trailing comma is optional in blockLit, see https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto#L1026 for example. There are other examples in that file that use trailing commas as list delimiters. I think this change is probably also required by #4631 to be fully correct, but it is somewhat independent of that issue. --- protobuf/protobuf2/Protobuf2.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/protobuf2/Protobuf2.g4 b/protobuf/protobuf2/Protobuf2.g4 index 437349b2d3..ce562e2715 100644 --- a/protobuf/protobuf2/Protobuf2.g4 +++ b/protobuf/protobuf2/Protobuf2.g4 @@ -266,7 +266,7 @@ constant // not specified in specification but used in tests blockLit - : LC (ident COLON constant)* RC + : LC (ident COLON constant (COMMA)?)* RC ; emptyStatement_ From b8405a9a87ab1a1264ba4237c22c12d2001aaaed Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 26 Sep 2025 09:44:00 +0000 Subject: [PATCH 2/2] Add example with blockLits --- protobuf/protobuf2/examples/block.proto | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 protobuf/protobuf2/examples/block.proto diff --git a/protobuf/protobuf2/examples/block.proto b/protobuf/protobuf2/examples/block.proto new file mode 100644 index 0000000000..5db19068a2 --- /dev/null +++ b/protobuf/protobuf2/examples/block.proto @@ -0,0 +1,22 @@ +syntax = 'proto2'; + +// Extracted from google/protobuf/descriptor.proto +message FeatureSet { + enum FieldPresence { + FIELD_PRESENCE_UNKNOWN = 0; + EXPLICIT = 1; + IMPLICIT = 2; + LEGACY_REQUIRED = 3; + } + optional FieldPresence field_presence = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" }, + edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" }, + edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" } + ]; +} \ No newline at end of file