Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoparse: weird multi-line type references #223

Closed
jhump opened this issue Jun 12, 2019 · 2 comments · Fixed by #262
Closed

protoparse: weird multi-line type references #223

jhump opened this issue Jun 12, 2019 · 2 comments · Fixed by #262

Comments

@jhump
Copy link
Owner

jhump commented Jun 12, 2019

It turns out that the grammar in protoc parses qualified identifiers in a very different way from the protoparse package. It supports arbitrary whitespace in between name components and the dot separators. Both of the following, for example, are accepted by protoc:

syntax = "proto3";

package foo.bar;

message Baz {
  // spaces between name components and dots
  foo.  bar . Baz child = 1;
}

message Blah {
  // newlines, too!
  foo.
    bar
      . Baz
        child = 1;
}

Neither of these are accepted by the protoparse package. This package only allows whitespaces between name components and dots if it occurs after the name component and before the dot. Files that use whitespace after the dot but before the subsequent name component are rejected with a syntax error like so:

t.proto:6:6: syntax error: unexpected '.'

This requires a change to the grammar so that qualified identifiers are recognized by productions in the grammar, vs. being recognized by the lexer.

cc @pedgeio

@jhump
Copy link
Owner Author

jhump commented Jun 12, 2019

#211 attempted to fix this issue. But it only fixed one class of issues that surfaced in some of the Google API protobufs. A proper fix, to be just as flexible as protoc, will require a slightly more involved change.

@bufdev
Copy link
Contributor

bufdev commented Jun 12, 2019

We should maybe start mentioning protocolbuffers/protobuf#6188 in these kinds of issues to keep track heh. I'm thinking eventually for that issue that your grammar might be the starting point for https://github.com/protocolbuffers/protobuf-grammar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants