-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
Description
There's an assumption with the protobuf grammars in that one syntax cannot include another (previous) version. That's patently false with this example and compilation.
07/19-16:54:37 ~/issues/g4-current/protobuf/protobuf3/examples
$ cat 8.proto
syntax="proto3";
import "google/protobuf/descriptor.proto";
message SearchResponse {
repeated google.protobuf.FileDescriptorProto results = 1;
}
07/19-16:54:42 ~/issues/g4-current/protobuf/protobuf3/examples
$ grep syntax google/protobuf/descriptor.proto
syntax = "proto2";
// The syntax of the proto file.
optional string syntax = 12;
// NOTE: Do not set the option in .proto files. Always use the maps syntax
07/19-16:54:51 ~/issues/g4-current/protobuf/protobuf3/examples
$ p 8.proto --csharp_out=xxx
07/19-16:55:06 ~/issues/g4-current/protobuf/protobuf3/examples
$ wc xxx/*
228 560 8209 xxx/8.cs
07/19-16:55:11 ~/issues/g4-current/protobuf/protobuf3/examples
$
Currently, we have two protobuf grammars, one for version2, the other for version 3. This example gives a contraditory example, where a proto3 file imports a proto2 file. The protobuf grammars are wrong. There should be one grammar that switches syntaxes, or the "DoRewind()" code in the protobuf3 grammar should test and load a parser for the appropriate syntax.