From 20229b7331ee14ceac964a423a56c73cc8f85a9b Mon Sep 17 00:00:00 2001 From: heroicNeZha <25311962+heroicNeZha@users.noreply.github.com> Date: Thu, 9 Dec 2021 10:17:26 +0800 Subject: [PATCH] Schema support mixed Chinese and English --- src/parser/parser.yy | 4 ++-- src/parser/scanner.lex | 9 ++++++--- tests/tck/features/schema/Schema.feature | 13 +++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 0ea8ede2672..bcd876c2425 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -213,7 +213,7 @@ static constexpr size_t kCommentLengthLimit = 256; %token BOOL %token INTEGER %token DOUBLE -%token STRING VARIABLE LABEL IPV4 CHINESE_LABEL +%token STRING VARIABLE LABEL IPV4 UTF8_LABEL %type name_label unreserved_keyword predicate_name %type expression @@ -406,7 +406,7 @@ static constexpr size_t kCommentLengthLimit = 256; name_label : LABEL { $$ = $1; } - | CHINESE_LABEL { $$ = $1; } + | UTF8_LABEL { $$ = $1; } | unreserved_keyword { $$ = $1; } ; diff --git a/src/parser/scanner.lex b/src/parser/scanner.lex index 4fe773332d2..07bb0834efb 100644 --- a/src/parser/scanner.lex +++ b/src/parser/scanner.lex @@ -47,7 +47,10 @@ U [\x80-\xbf] U2 [\xc2-\xdf] U3 [\xe0-\xef] U4 [\xf0-\xf4] -CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+ +CHINESE {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} +CN_EN {CHINESE}|[a-zA-Z] +CN_EN_NUM {CHINESE}|[_a-zA-Z0-9] +UTF8_LABEL {CN_EN}{CN_EN_NUM}+ %% @@ -471,7 +474,7 @@ CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+ // Must match /* */ throw GraphParser::syntax_error(*yylloc, "unterminated comment"); } -\`{CHINESE_LABEL}\` { +\`{UTF8_LABEL}\` { yylval->strval = new std::string(yytext + 1, yyleng - 2); if (yylval->strval->size() > MAX_STRING) { auto error = "Out of range of the LABEL length, " @@ -480,7 +483,7 @@ CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+ delete yylval->strval; throw GraphParser::syntax_error(*yylloc, error); } - return TokenType::CHINESE_LABEL; + return TokenType::UTF8_LABEL; } . { /** diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index f30f79a6d27..52b65149ebb 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -832,6 +832,19 @@ Feature: Insert string vid of vertex and edge Then the result should be, in any order: | Field | Type | Null | Default | Comment | | "时间" | "timestamp" | "YES" | EMPTY | EMPTY | + When executing query: + """ + CREATE TAG `队伍s2`(`名s字ss1` string); + """ + Then the execution should be successful + # desc cn-en mixed tag + When executing query: + """ + DESCRIBE TAG `队伍s2` + """ + Then the result should be, in any order: + | Field | Type | Null | Default | Comment | + | "名s字ss1" | "string" | "YES" | EMPTY | EMPTY | When executing query: """ DROP SPACE issue2009;