Skip to content

Commit

Permalink
merge UTF-LABEL to LABEL
Browse files Browse the repository at this point in the history
  • Loading branch information
heroicNeZha committed Dec 9, 2021
1 parent 20229b7 commit 677d92a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static constexpr size_t kCommentLengthLimit = 256;
%token <boolval> BOOL
%token <intval> INTEGER
%token <doubleval> DOUBLE
%token <strval> STRING VARIABLE LABEL IPV4 UTF8_LABEL
%token <strval> STRING VARIABLE LABEL IPV4

%type <strval> name_label unreserved_keyword predicate_name
%type <expr> expression
Expand Down Expand Up @@ -406,7 +406,6 @@ static constexpr size_t kCommentLengthLimit = 256;

name_label
: LABEL { $$ = $1; }
| UTF8_LABEL { $$ = $1; }
| unreserved_keyword { $$ = $1; }
;

Expand Down
26 changes: 7 additions & 19 deletions src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@ IS_NOT_NULL (IS{blanks}NOT{blanks}NULL)
IS_EMPTY (IS{blanks}EMPTY)
IS_NOT_EMPTY (IS{blanks}NOT{blanks}EMPTY)

LABEL ([a-zA-Z][_a-zA-Z0-9]*)
DEC ([0-9])
EXP ([eE][-+]?[0-9]+)
HEX ([0-9a-fA-F])
OCT ([0-7])
IP_OCTET ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])

U [\x80-\xbf]
U2 [\xc2-\xdf]
U3 [\xe0-\xef]
U4 [\xf0-\xf4]
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}+

LABEL {CN_EN}{CN_EN_NUM}*
DEC ([0-9])
EXP ([eE][-+]?[0-9]+)
HEX ([0-9a-fA-F])
OCT ([0-7])
IP_OCTET ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])

%%

Expand Down Expand Up @@ -474,17 +473,6 @@ UTF8_LABEL {CN_EN}{CN_EN_NUM}+
// Must match /* */
throw GraphParser::syntax_error(*yylloc, "unterminated comment");
}
\`{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, "
"the max length of LABEL is " +
std::to_string(MAX_STRING) + ":";
delete yylval->strval;
throw GraphParser::syntax_error(*yylloc, error);
}
return TokenType::UTF8_LABEL;
}
. {
/**
* Any other unmatched byte sequences will get us here,
Expand Down

0 comments on commit 677d92a

Please sign in to comment.