Closed knivil closed 2 years ago
Issue with proto3 example: Can not parse this simple proto-file
syntax = "proto3"; enum Error { hello = 0; }
Reason: int_lit does not allow for a single zero, which is understandable for field numbers in messages, but field numbers in enum start at zero.
struct dec_lit : seq< range< '1', '9' >, star< digit > > {}; struct int_lit : sor< hex_lit, oct_lit, dec_lit > {}; struct enum_field : ... ident, sps, equ, sps, int_lit, ...
A possible solution is to introduce enum_number that allows zero.
enum_number
Ref: There must be a zero value, so that we can use 0 as a numeric default value https://developers.google.com/protocol-buffers/docs/proto3#enum
I know that the grammar suffers from same issue.
So there was a bug in the original grammar that I copied into the PEGTL grammar. I'll change enum_field to use a new rule enum_int that uses enum_dec aka. plus< digit > instead of dec_lit.
enum_field
enum_int
enum_dec
plus< digit >
dec_lit
Issue with proto3 example: Can not parse this simple proto-file
Reason: int_lit does not allow for a single zero, which is understandable for field numbers in messages, but field numbers in enum start at zero.
A possible solution is to introduce
enum_number
that allows zero.Ref: There must be a zero value, so that we can use 0 as a numeric default value https://developers.google.com/protocol-buffers/docs/proto3#enum