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

Online grammar debug/documentation/development #217

Open
mingodad opened this issue Sep 12, 2023 · 4 comments
Open

Online grammar debug/documentation/development #217

mingodad opened this issue Sep 12, 2023 · 4 comments

Comments

@mingodad
Copy link

I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ (select Protobuf3 parser under examples then click Parse to see the parser tree).

I hope it can help develop/debug/extend/test/document the grammar used in this project.

I did some changes there:

  • Converted right recursion to left recursion.
  • Eliminate some redundant? rules to simplify the parser tree (proto_content : * proto removed and added proto_content_oom )

Any feedback is welcome !

@c-cube
Copy link
Collaborator

c-cube commented Sep 19, 2023

Oh that's cool, I looked the other day and it wasn't working but now it is! Very neat :)

@mingodad
Copy link
Author

I just found an example that this grammar doesn't seem to accept in https://github.com/electric-sql/electric/blob/main/protocol/satellite.proto :

enum SatAuthHeader {
    reserved 1;
    // Required by the Protobuf spec.
    UNSPECIFIED = 0;
}

There is no rule to accept reserved 1;.

@mingodad
Copy link
Author

Changing the grammar like this seems to fix the problem:

enum_body_content :
	option
	| enum_value
	| reserved   //<<<   adding this rule
	;

See documentation here https://protobuf.dev/programming-guides/proto3/#reserved

@mingodad
Copy link
Author

The above can be tested on https://mingodad.github.io/parsertl-playground/playground/ 👍

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

No branches or pull requests

2 participants