ocaml-protoc
ocaml-protoc copied to clipboard
Online grammar debug/documentation/development
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 : * protoremoved and addedproto_content_oom)
Any feedback is welcome !
Oh that's cool, I looked the other day and it wasn't working but now it is! Very neat :)
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;.
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
The above can be tested on https://mingodad.github.io/parsertl-playground/playground/ :+1: