Skip to content

Commit

Permalink
use "-- " as comment prefix (vesoft-inc#2115)
Browse files Browse the repository at this point in the history
Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
  • Loading branch information
laura-ding and dutor authored May 11, 2020
1 parent e6c5531 commit 85173fa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/graph/test/YieldTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,29 @@ TEST_F(YieldTest, PipeYieldGo) {
ASSERT_TRUE(verifyResult(resp, expected));
}
}

TEST_F(YieldTest, WithComment) {
{
cpp2::ExecutionResponse resp;
auto code = client_->execute("YIELD 1--1", resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << resp.get_error_msg();

std::vector<std::tuple<int64_t>> expected = {
{2},
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto code = client_->execute("YIELD 1-- 1", resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << resp.get_error_msg();

std::vector<std::tuple<int64_t>> expected = {
{1},
};
ASSERT_TRUE(verifyResult(resp, expected));
}
}
} // namespace graph
} // namespace nebula

2 changes: 1 addition & 1 deletion src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ RECOVER ([Rr][Ee][Cc][Oo][Vv][Ee][Rr])
}
"#".* // Skip the annotation
"//".* // Skip the annotation
"--".* // Skip the annotation
"-- ".* // Skip the annotation
"/*" { BEGIN(COMMENT); }
<COMMENT>"*/" { BEGIN(INITIAL); }
<COMMENT>([^*]|\n)+|.
Expand Down
7 changes: 7 additions & 0 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,13 @@ TEST(Parser, Annotation) {
auto result = parser.parse(query);
ASSERT_TRUE(result.status().isStatementEmpty());
}
// need use space after "--"
{
GQLParser parser;
std::string query = "--test comment....";
auto result = parser.parse(query);
ASSERT_FALSE(result.ok());
}
{
GQLParser parser;
std::string query = "-- test comment....";
Expand Down

0 comments on commit 85173fa

Please sign in to comment.