protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
64.65k stars 15.37k forks source link

Grammar does not allow more than one parenthesized identifier. #1187

Open JakeWharton opened 8 years ago

JakeWharton commented 8 years ago

Defined as

option = "option" optionName  "=" constant ";"
optionName = ( ident | "(" fullIdent ")" ) { "." ident }

with

ident = letter { letter | unicodeDigit | "_" }
fullIdent = ident { "." ident }

yet in unittest_custom_options.proto there's:

message VariousComplexOptions {
  option (.protobuf_unittest.complex_opt1).foo = 42;
  option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324;
  option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876;
  option (protobuf_unittest.complex_opt1).foo4 = 99;
  option (protobuf_unittest.complex_opt1).foo4 = 88;
  option (complex_opt2).baz = 987;
  option (complex_opt2).(grault) = 654;
  option (complex_opt2).bar.foo = 743;
  option (complex_opt2).bar.(quux) = 1999;
  option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008;
  option (complex_opt2).(garply).foo = 741;
  option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998;
  option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121;
  option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;
  option (complex_opt2).fred.waldo = 321;
  option (complex_opt2).barney = { waldo: 101 };
  option (complex_opt2).barney = { waldo: 212 };
  option (protobuf_unittest.complex_opt3).qux = 9;
  option (complex_opt3).complexoptiontype5.plugh = 22;
  option (complexopt6).xyzzy = 24;
}

half of which have multiple parenthesized identifiers.

haberman commented 8 years ago

@LisaFC looks like this is worth investigating.

By the way, @JakeWharton do you have your own .proto file parser? Would be curious to know the use case for that.

JakeWharton commented 8 years ago

We have systems which need to parse, read, and write protos dynamically at runtime in Java. We also ship our own "compiler" and Java runtime which generates files that are much more terse than protoc's Java format but not as crazy as the choices made by JavaNano. The latter is targeted at Android.

anandolee commented 6 years ago

How about optionName = ( ident | bracedFullIdent ) { "." ( ident | bracedFullIdent ) } bracedFullIdent = "(" ["."] fullIdent ")"

elharo commented 2 years ago

correct spec

Logofile commented 6 months ago

I'm working on correcting the spec based on the suggestion from @anandolee and the updates already made to the proto3 spec.

github-actions[bot] commented 3 weeks ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

elharo commented 3 weeks ago

@Logofile what's the status on this? Issue should remain open until fixed. (and that bot really needs to be turned off. It's actively rude to volunteer contributors.)

Logofile commented 3 weeks ago

I've sent a change to @anandolee to review.

Logofile commented 3 weeks ago

The change has been committed internally. We push internal change to the external site about once a week.