Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Extend white space in unicode. #4959

Merged
merged 7 commits into from
Dec 1, 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
7 changes: 5 additions & 2 deletions src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ static constexpr size_t MAX_STRING = 4096;
%x LB_STR
%x COMMENT

blanks ([ \t\n]+)
blank_without_newline ([ \t\r\xa0])
blank ({blank_without_newline}|[\n])

blanks ({blank}+)

NOT_IN (NOT{blanks}IN)
NOT_CONTAINS (NOT{blanks}CONTAINS)
Expand Down Expand Up @@ -514,7 +517,7 @@ LABEL_FULL_WIDTH {CN_EN_FULL_WIDTH}{CN_EN_NUM_FULL_WIDTH}*
throw GraphParser::syntax_error(*yylloc, "Don't allow DOT in label:");
}

[ \r\t] { }
{blank_without_newline} { }
\n {
yylineno++;
yylloc->lines(yyleng);
Expand Down
5 changes: 5 additions & 0 deletions src/parser/test/ScannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ TEST(Scanner, Basic) {

CHECK_SEMANTIC_VALUE("label", TokenType::LABEL, "label"),
CHECK_SEMANTIC_VALUE("label123", TokenType::LABEL, "label123"),
// \xA0 is white space in UTF-8 too
CHECK_SEMANTIC_VALUE("\xA0"
"abc",
TokenType::LABEL,
"abc"),

CHECK_SEMANTIC_VALUE("123", TokenType::INTEGER, 123),
CHECK_SEMANTIC_VALUE("0x123", TokenType::INTEGER, 0x123),
Expand Down