diff --git a/protobuf/protobuf2/Protobuf2.g4 b/protobuf/protobuf2/Protobuf2.g4 index 83892abb5b..253cc8b43a 100644 --- a/protobuf/protobuf2/Protobuf2.g4 +++ b/protobuf/protobuf2/Protobuf2.g4 @@ -132,7 +132,24 @@ type_ // Extensions extensions - : EXTENSIONS ranges SEMI + : EXTENSIONS ranges (LB (verificationDef | declarations) RB)? SEMI + ; + +verificationDef + : VERIFICATION EQ verification + ; + +verification + : DECLARATION_LIT + | UNVERIFIED_LIT + ; + +declarations + : declaration (COMMA declaration)* + ; + +declaration + : DECLARATION EQ blockLit ; // Reserved @@ -472,6 +489,22 @@ MAX : 'max' ; +VERIFICATION + : 'verification' + ; + +DECLARATION + : 'declaration' + ; + +DECLARATION_LIT + : 'DECLARATION' + ; + +UNVERIFIED_LIT + : 'UNVERIFIED' + ; + ENUM : 'enum' ; @@ -707,4 +740,8 @@ keywords | STREAM | RETURNS | BOOL_LIT + | DECLARATION + | VERIFICATION + | DECLARATION_LIT + | UNVERIFIED_LIT ; diff --git a/protobuf/protobuf2/examples/extension.proto b/protobuf/protobuf2/examples/extension.proto new file mode 100644 index 0000000000..41b2936aa4 --- /dev/null +++ b/protobuf/protobuf2/examples/extension.proto @@ -0,0 +1,16 @@ +syntax = 'proto2'; + +message UserContent { + extensions 100 to 199 [verification = DECLARATION]; +} + +message OtherContent { + extensions 100 to 199 [ + declaration = { + number: 126, + full_name: ".kittens.kitten_videos", + type: ".kittens.Video", + repeated: true + } + ]; +} \ No newline at end of file