Skip to content

Commit 637b80c

Browse files
j6tgitster
authored andcommitted
userdiff-cpp: permit the digit-separating single-quote in numbers
Since C++17, the single-quote can be used as digit separator: 3.141'592'654 1'000'000 0xdead'beaf Make it known to the word regex of the cpp driver, so that numbers are not split into separate tokens at the single-quotes. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfaaf19 commit 637b80c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

t/t4034/cpp/expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <RED>foo0<RESET><GREEN>bar<RESET>
77
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
88
<GREEN>(<RESET>1 <RED>-<RESET><GREEN>+<RESET>1e10 0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>.<RESET>'
99
// long double<RESET>
10-
3.141'592'<RED>653e-10l<RESET><GREEN>654e+10l<RESET>
10+
<RED>3.141'592'653e-10l<RESET><GREEN>3.141'592'654e+10l<RESET>
1111
// float<RESET>
1212
<RED>120E5f<RESET><GREEN>120E6f<RESET>
1313
// hex<RESET>
14-
0xdead'<RED>beaf<RESET><GREEN>Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
14+
<RED>0xdead'beaf<RESET><GREEN>0xdead'Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
1515
// octal<RESET>
16-
0123'<RED>4567<RESET><GREEN>4560<RESET>
16+
<RED>0123'4567<RESET><GREEN>0123'4560<RESET>
1717
// binary<RESET>
18-
<RED>0b10<RESET><GREEN>0b11<RESET>'00+e1
18+
<RED>0b10'00<RESET><GREEN>0b11'00<RESET>+e1
1919
// expression<RESET>
2020
1.5-e+<RED>2<RESET><GREEN>3<RESET>+f
2121
// another one<RESET>

userdiff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ PATTERNS("cpp",
6767
/* identifiers and keywords */
6868
"[a-zA-Z_][a-zA-Z0-9_]*"
6969
/* decimal and octal integers as well as floatingpoint numbers */
70-
"|[0-9][0-9.]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
70+
"|[0-9][0-9.']*([Ee][-+]?[0-9]+)?[fFlLuU]*"
7171
/* hexadecimal and binary integers */
72-
"|0[xXbB][0-9a-fA-F]+[lLuU]*"
72+
"|0[xXbB][0-9a-fA-F']+[lLuU]*"
7373
/* floatingpoint numbers that begin with a decimal point */
74-
"|\\.[0-9]+([Ee][-+]?[0-9]+)?[fFlL]?"
74+
"|\\.[0-9][0-9']*([Ee][-+]?[0-9]+)?[fFlL]?"
7575
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
7676
PATTERNS("csharp",
7777
/* Keywords */

0 commit comments

Comments
 (0)