Skip to content

Commit f3f157f

Browse files
committed
Merge branch 'js/userdiff-cpp'
Userdiff patterns for the C++ language has been updated. * js/userdiff-cpp: userdiff-cpp: back out the digit-separators in numbers userdiff-cpp: learn the C++ spaceship operator userdiff-cpp: permit the digit-separating single-quote in numbers userdiff-cpp: prepare test cases with yet unsupported features userdiff-cpp: tighten word regex t4034: add tests showing problematic cpp tokenizations t4034/cpp: actually test that operator tokens are not split
2 parents 6a1bb08 + 386076e commit f3f157f

File tree

4 files changed

+94
-67
lines changed

4 files changed

+94
-67
lines changed

t/t4034/cpp/expect

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
<BOLD>diff --git a/pre b/post<RESET>
2-
<BOLD>index 23d5c8a..7e8c026 100644<RESET>
2+
<BOLD>index a1a09b7..f1b6f3c 100644<RESET>
33
<BOLD>--- a/pre<RESET>
44
<BOLD>+++ b/post<RESET>
5-
<CYAN>@@ -1,19 +1,19 @@<RESET>
6-
Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <GREEN>bar(x);<RESET> }
5+
<CYAN>@@ -1,30 +1,30 @@<RESET>
6+
Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <RED>foo0<RESET><GREEN>bar<RESET>(x.<RED>find<RESET><GREEN>Find<RESET>); }
77
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
8-
<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>'
9-
[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET>
10-
!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET>
11-
<RED>a<RESET><GREEN>y<RESET>
12-
<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET>
13-
<RED>a<RESET><GREEN>y<RESET>
14-
<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
15-
<RED>a<RESET><GREEN>y<RESET>
16-
<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b<RESET>
17-
<RED>a<RESET><GREEN>y<RESET>
18-
<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
19-
<RED>a<RESET><GREEN>y<RESET>
20-
<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b<RESET>
21-
<RED>a<RESET><GREEN>y<RESET>
22-
<GREEN>x<RESET>&<RED>b<RESET>
23-
<RED>a<RESET><GREEN>y<RESET>
24-
<GREEN>x<RESET>^<RED>b<RESET>
25-
<RED>a<RESET><GREEN>y<RESET>
26-
<GREEN>x<RESET>|<RED>b<RESET>
27-
<RED>a<RESET><GREEN>y<RESET>
28-
<GREEN>x<RESET>&&<RED>b<RESET>
29-
<RED>a<RESET><GREEN>y<RESET>
30-
<GREEN>x<RESET>||<RED>b<RESET>
31-
<RED>a<RESET><GREEN>y<RESET>
32-
<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
33-
<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET>
34-
<RED>a<RESET><GREEN>y<RESET>
35-
<GREEN>x<RESET>,y
36-
<RED>a<RESET><GREEN>x<RESET>::<RED>b<RESET><GREEN>y<RESET>
8+
<GREEN>(<RESET>1 <RED>-<RESET><GREEN>+<RESET>1e10 0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>2<RESET>'
9+
// long double<RESET>
10+
<RED>3.141592653e-10l<RESET><GREEN>3.141592654e+10l<RESET>
11+
// float<RESET>
12+
<RED>120E5f<RESET><GREEN>120E6f<RESET>
13+
// hex<RESET>
14+
<RED>0xdead<RESET><GREEN>0xdeaf<RESET>'1<RED>eaF<RESET><GREEN>eaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
15+
// octal<RESET>
16+
<RED>01234567<RESET><GREEN>01234560<RESET>
17+
// binary<RESET>
18+
<RED>0b1000<RESET><GREEN>0b1100<RESET>+e1
19+
// expression<RESET>
20+
1.5-e+<RED>2<RESET><GREEN>3<RESET>+f
21+
// another one<RESET>
22+
str.e+<RED>65<RESET><GREEN>75<RESET>
23+
[a] b<RED>-><RESET><GREEN>->*<RESET>v d<RED>.<RESET><GREEN>.*<RESET>e
24+
<GREEN>~<RESET>!a <GREEN>!<RESET>~b c<RED>++<RESET><GREEN>+<RESET> d<RED>--<RESET><GREEN>-<RESET> e*<GREEN>*<RESET>f g<RED>&<RESET><GREEN>&&<RESET>h
25+
a<RED>*<RESET><GREEN>*=<RESET>b c<RED>/<RESET><GREEN>/=<RESET>d e<RED>%<RESET><GREEN>%=<RESET>f
26+
a<RED>+<RESET><GREEN>++<RESET>b c<RED>-<RESET><GREEN>--<RESET>d
27+
a<RED><<<RESET><GREEN><<=<RESET>b c<RED>>><RESET><GREEN>>>=<RESET>d
28+
a<RED><<RESET><GREEN><=<RESET>b c<RED><=<RESET><GREEN><<RESET>d e<RED>><RESET><GREEN>>=<RESET>f g<RED>>=<RESET><GREEN>><RESET>h i<RED><=<RESET><GREEN><=><RESET>j
29+
a<RED>==<RESET><GREEN>!=<RESET>b c<RED>!=<RESET><GREEN>=<RESET>d
30+
a<RED>^<RESET><GREEN>^=<RESET>b c<RED>|<RESET><GREEN>|=<RESET>d e<RED>&&<RESET><GREEN>&=<RESET>f
31+
a<RED>||<RESET><GREEN>|<RESET>b
32+
a?<GREEN>:<RESET>b
33+
a<RED>=<RESET><GREEN>==<RESET>b c<RED>+=<RESET><GREEN>+<RESET>d e<RED>-=<RESET><GREEN>-<RESET>f g<RED>*=<RESET><GREEN>*<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v
34+
a,b<RESET>
35+
a<RED>::<RESET><GREEN>:<RESET>b

t/t4034/cpp/post

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
Foo() : x(0&42) { bar(x); }
1+
Foo() : x(0&42) { bar(x.Find); }
22
cout<<"Hello World?\n"<<endl;
3-
(1) (-1e10) (0xabcdef) 'y'
4-
[x] x->y x.y
5-
!x ~x x++ x-- x*y x&y
6-
x*y x/y x%y
7-
x+y x-y
8-
x<<y x>>y
9-
x<y x<=y x>y x>=y
10-
x==y x!=y
11-
x&y
12-
x^y
13-
x|y
14-
x&&y
15-
x||y
16-
x?y:z
17-
x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y
18-
x,y
19-
x::y
3+
(1 +1e10 0xabcdef) '2'
4+
// long double
5+
3.141592654e+10l
6+
// float
7+
120E6f
8+
// hex
9+
0xdeaf'1eaf+7ULL
10+
// octal
11+
01234560
12+
// binary
13+
0b1100+e1
14+
// expression
15+
1.5-e+3+f
16+
// another one
17+
str.e+75
18+
[a] b->*v d.*e
19+
~!a !~b c+ d- e**f g&&h
20+
a*=b c/=d e%=f
21+
a++b c--d
22+
a<<=b c>>=d
23+
a<=b c<d e>=f g>h i<=>j
24+
a!=b c=d
25+
a^=b c|=d e&=f
26+
a|b
27+
a?:b
28+
a==b c+d e-f g*h i/j k%l m<<n o>>p q&r s^t u|v
29+
a,b
30+
a:b

t/t4034/cpp/pre

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
Foo():x(0&&1){}
1+
Foo():x(0&&1){ foo0( x.find); }
22
cout<<"Hello World!\n"<<endl;
33
1 -1e10 0xabcdef 'x'
4-
[a] a->b a.b
5-
!a ~a a++ a-- a*b a&b
6-
a*b a/b a%b
7-
a+b a-b
8-
a<<b a>>b
9-
a<b a<=b a>b a>=b
10-
a==b a!=b
11-
a&b
12-
a^b
13-
a|b
14-
a&&b
4+
// long double
5+
3.141592653e-10l
6+
// float
7+
120E5f
8+
// hex
9+
0xdead'1eaF+8ULL
10+
// octal
11+
01234567
12+
// binary
13+
0b1000+e1
14+
// expression
15+
1.5-e+2+f
16+
// another one
17+
str.e+65
18+
[a] b->v d.e
19+
!a ~b c++ d-- e*f g&h
20+
a*b c/d e%f
21+
a+b c-d
22+
a<<b c>>d
23+
a<b c<=d e>f g>=h i<=j
24+
a==b c!=d
25+
a^b c|d e&&f
1526
a||b
16-
a?b:z
17-
a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
18-
a,y
27+
a?b
28+
a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v
29+
a,b
1930
a::b

userdiff.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ PATTERNS("cpp",
6464
/* functions/methods, variables, and compounds at top level */
6565
"^((::[[:space:]]*)?[A-Za-z_].*)$",
6666
/* -- */
67+
/* identifiers and keywords */
6768
"[a-zA-Z_][a-zA-Z0-9_]*"
68-
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*"
69-
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
69+
/* decimal and octal integers as well as floatingpoint numbers */
70+
"|[0-9][0-9.]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
71+
/* hexadecimal and binary integers */
72+
"|0[xXbB][0-9a-fA-F]+[lLuU]*"
73+
/* floatingpoint numbers that begin with a decimal point */
74+
"|\\.[0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlL]?"
75+
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*|<=>"),
7076
PATTERNS("csharp",
7177
/* Keywords */
7278
"!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n"

0 commit comments

Comments
 (0)