| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -549,6 +549,10 @@ auto to_string(std::optional<T> const& o) -> std::string { | |||
| 549 | 549 | return "(empty)"; | |
| 550 | 550 | } | |
| 551 | 551 | ||
| 552 | + auto to_string(...) -> std::string { | ||
| 553 | + return "(customize me - no cpp2::to_string overload exists for this type)"; | ||
| 554 | + } | ||
| 555 | + | ||
| 552 | 556 | ||
| 553 | 557 | } | |
| 554 | 558 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -890,6 +890,10 @@ class cppfront | |||
| 890 | 890 | // Scan back to find the matching ( | |
| 891 | 891 | auto paren_depth = 1; | |
| 892 | 892 | auto open = pos - 2; | |
| 893 | + | ||
| 894 | + // "next" in the string is the "last" one encountered in the backwards scan | ||
| 895 | + auto last_nonwhitespace = '\0'; | ||
| 896 | + | ||
| 893 | 897 | for( ; text[open] != '"'; --open) | |
| 894 | 898 | { | |
| 895 | 899 | if (text[open] == ')') { | |
@@ -902,7 +906,7 @@ class cppfront | |||
| 902 | 906 | } | |
| 903 | 907 | } | |
| 904 | 908 | else if ( | |
| 905 | - (text[open] == '-' && text[open - 1] == '-') || | ||
| 909 | + (text[open] == '+' && text[open - 1] == '+') || | ||
| 906 | 910 | (text[open] == '-' && text[open - 1] == '-') | |
| 907 | 911 | ) | |
| 908 | 912 | { | |
@@ -913,17 +917,21 @@ class cppfront | |||
| 913 | 917 | return ""; | |
| 914 | 918 | } | |
| 915 | 919 | else if ( | |
| 916 | - (text[open] == '*' && !isspace(text[open - 1])) || | ||
| 917 | - (text[open] == '&' && !isspace(text[open - 1])) || | ||
| 918 | - (text[open] == '!' && !isspace(text[open - 1])) | ||
| 920 | + (text[open] == '*' || text[open] == '&' || text[open] == '~') && | ||
| 921 | + !isspace(text[open - 1]) && | ||
| 922 | + !isalnum(last_nonwhitespace) && last_nonwhitespace != '(' | ||
| 919 | 923 | ) | |
| 920 | 924 | { | |
| 921 | 925 | errors.emplace_back( | |
| 922 | 926 | source_position( n.position().lineno, n.position().colno + pos ), | |
| 923 | - "a string interpolation expression may not contain unary *, &, or ~ (if you meant binary, add a space before the operator)" | ||
| 927 | + "a string interpolation expression may not contain unary & * or ~" | ||
| 924 | 928 | ); | |
| 925 | 929 | return ""; | |
| 926 | 930 | } | |
| 931 | + | ||
| 932 | + if (!std::isspace(text[open])) { | ||
| 933 | + last_nonwhitespace = text[open]; | ||
| 934 | + } | ||
| 927 | 935 | } | |
| 928 | 936 | if (text[open] == '"') | |
| 929 | 937 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1301,6 +1301,13 @@ class parser | |||
| 1301 | 1301 | curr().type() == lexeme::Dot | |
| 1302 | 1302 | ) | |
| 1303 | 1303 | { | |
| 1304 | + // * & and ~ can't be a unary operator if followed by ( or identifier | ||
| 1305 | + if ((curr().type() == lexeme::Multiply || curr().type() == lexeme::Ampersand || curr().type() == lexeme::Tilde) && | ||
| 1306 | + (peek(1)->type() == lexeme::LeftParen || peek(1)->type() == lexeme::Identifier)) | ||
| 1307 | + { | ||
| 1308 | + break; | ||
| 1309 | + } | ||
| 1310 | + | ||
| 1304 | 1311 | if (curr().type() == lexeme::Dollar) { | |
| 1305 | 1312 | // cap_grp must not already be set, or this is a multi-$ postfix-expression | |
| 1306 | 1313 | if (n->cap_grp) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments