Skip to content

Commit

Permalink
Merge pull request #18 from Matts966/hotfix/newline
Browse files Browse the repository at this point in the history
Fix redundant newline
  • Loading branch information
Matts966 authored Apr 24, 2022
2 parents 79b6815 + e2f3af2 commit d90f045
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit d90f045

Please # to comment.