don't put NoSourceNode into a *FileNode #38
Merged
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.
The
buf
repo is using an earlier revision of protocompile, under the monikergithub.com/jhump/protocompile
, for formatting.While integrating protocompile into the
buf build
command, I was also removing this old dependency and updating the format command to use the latest version of this repo (the one under the bufbuild organization).While debugging some discrepancies, I encountered a bug in this repo: an empty file resulted in an AST that would cause a panic when trying to visit/walk the AST. The problem is that it would store a
NoSourceNode
into the empty file node -- but that is a special placeholder node that means there is no AST, so it is (intentionally) not handled by the visit/walk functionality.This fixes it. An empty file now looks like a normal file, but with no declarations. The singular token in the AST is now just the EOF token. (The reason a
NoSourceNode
was previously used was just to have some singular token, because the implementation ofcompositeNode
gets cranky if it has zero children.) I also updated the grammar to produce a valid AST for an empty file (previously, it was only handled in a special check after the parser completed). That allows the AST for an empty file to still retain information about comments and whitespace (so "empty file" really meaning no tokens/lexical elements, not necessarily no bytes).