[protobuf2] The applied occurrence of `syntax` should not be mandatory.
- Dominant language
- ANTLR
- Stars
- 11.1k
- Forks
- 3.8k
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 14
Description
In [protobuf2](https://github.com/antlr/grammars-v4/tree/6b517735620223475eefaa85c92f8d6bce15f360/protobuf/protobuf2), the syntax for `proto` has `syntax` as mandatory.
https://github.com/antlr/grammars-v4/blob/6b517735620223475eefaa85c92f8d6bce15f360/protobuf/protobuf2/Protobuf2.g4#L16-L18
This is wrong. The Protobuf2 spec says: `proto = [syntax] { import | package | option | topLevelDef | emptyStatement }` (https://protobuf.dev/reference/protobuf/proto3-spec/#proto_file).
Consequently, it fails to parse the first example in the Extensions section in the programming guide (https://protobuf.dev/programming-guides/proto2/#ext-example).
```
// file kittens/video_ext.proto
import "kittens/video.proto";
import "media/user_content.proto";
package kittens;
// This extension allows kitten videos in a media.UserContent message.
extend media.UserContent {
// Video is a message imported from kittens/video.proto
repeated Video kitten_videos = 126;
}
```
I mentioned this problem in another comment, https://github.com/antlr/grammars-v4/issues/4629#issuecomment-3337458963, chasing down another problem.
Contributor guide
No contributing guide indexed for this repository
Research direction
Open protobuf/protobuf2/Protobuf2.g4 at lines 16–18 and compare the proto rule with the cited protobuf2 specification. Make the syntax occurrence optional and verify that the Extensions example in the issue parses without requiring a syntax declaration.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100