Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix redundant newline #18

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions zetasql/parser/unparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ std::string Unparse(const ASTNode* node) {

std::string UnparseWithComments(const ASTNode* node, std::deque<std::pair<std::string,
ParseLocationPoint>>& parse_tokens) {
std::string unparsed_;
parser::Unparser unparser(&unparsed_);
std::string unparsed;
parser::Unparser unparser(&unparsed);
// Print comments by visitors and pop.
node->Accept(&unparser, &parse_tokens);
// Emit left comments in parse_tokens.
for (const auto& parse_token : parse_tokens) {
unparser.print(parse_token.first);
}
unparser.FlushLine();
return unparsed_;
while (unparsed.back() == '\n' && unparsed.at(unparsed.size() - 2) == '\n') {
unparsed.pop_back();
}
return unparsed;
}

namespace parser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ FROM
fuga
ON hoge.hoge = fuga.fuga;
-- comment3