0

I defined .proto file like:

syntax = "proto3";

message networkSliceArray
{

  int32 DRB.UEThpDl.SNSSAI = 1;

  int32 DRB.UEThpUl.SNSSAI = 2;

  string networkSliceIdentifier = 3;

}

I want to parse such type of file. is it possible? or if not possible is there any reference where i can find out why "." we can not used in protobuf. OR list of character that we can not defined in .proto file.

Rahman Haroon
  • 1,088
  • 2
  • 12
  • 36
  • 1
    Well if you want to parse the file yourself it's possible. However I guess you are asking can you make `protoc` accept this? If that is your question then the answer is no. See the [language specification](https://developers.google.com/protocol-buffers/docs/reference/proto3-spec)) for details of what constitutes a valid `proto3` file (esp. `ident = letter { letter | decimalDigit | "_" }`). – Brits Jun 20 '22 at 08:48
  • Why not using sub-messages to do what you want? Is it really just the name that you want like this or is it supposed to represent an object? – Clément Jean Jun 20 '22 at 10:14
  • @brits please consider copying your comment as the answer. – DazWilkin Jun 20 '22 at 23:53

1 Answers1

2

Your question is not really clear but I think you are asking why protoc outputs an error when processing the .proto file in your question.

The language specification sets out what constitutes a valid proto3 file. Your question is about field names so the relevant parts are:

field = [ "repeated" ] type fieldName "=" fieldNumber [ "[" fieldOptions "]" ] ";"
fieldName = ident
ident = letter { letter | decimalDigit | "_" }

This shows that a field name must start with a letter which can be followed by a combination of letters, digits and underscores. A period (.) is not valid.

Brits
  • 14,829
  • 2
  • 18
  • 31
  • Additional reasons: protoc internally represents type names as `"package.Message.Submessage"`, which would cause problems if the names contained a period in them. Most programming languages also forbid `.` in variable names. – jpa Jun 21 '22 at 05:58