compiler: Add participle-based protobuf parser #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a protobuf parser using participle, based on the example in Alec
Thomas's protobuf compiler. I have reworked the parser to be more how I
think it should look and to bring it closer to the BNF(ish) in the
protobuf spec. I have also removed comments from the grammar (they are
ignored like whitespace) since I don't believe the best way to handle
comments will be in the grammar (I am thinking of attaching comments to
tokens in the lexer; we'll see).
At the moment, the
protog
command just prints out the Go struct forthe parsed form of the protobuf. This will grow into something more
useful as the compiler evolves to be a proper compiler.
We bump the required Go version to 1.18 as there is a small use of
generics in the test code, but I also want to use generics wherever it
makes sense.
Link: https://github.com/alecthomas/participle
Link: https://github.com/alecthomas/protobuf
Link: https://developers.google.com/protocol-buffers/docs/reference/proto2-spec
Link: https://developers.google.com/protocol-buffers/docs/reference/proto3-spec