1- Prism . languages . v = Prism . languages . extend ( 'clike' , {
2- 'string' : [
3- {
4- pattern : / ` (?: \\ \` | \\ ? [ ^ \` ] { 1 , 2 } ) ` / , // using {1,2} instead of `u` flag for compatibility
5- alias : 'rune'
6- } ,
7- {
8- pattern : / r ? ( [ " ' ] ) (?: \\ (?: \r \n | [ \s \S ] ) | (? ! \1) [ ^ \\ \r \n ] ) * \1/ ,
9- alias : 'quoted-string' ,
10- greedy : true ,
11- inside : {
12- 'interpolation' : {
13- pattern : / ( (?: ^ | [ ^ \\ ] ) (?: \\ { 2 } ) * ) \$ (?: \{ [ ^ { } ] * \} | \w + (?: \. \w + (?: \( [ ^ \( \) ] * \) ) ? | \[ [ ^ \[ \] ] + \] ) * ) / ,
14- lookbehind : true ,
15- inside : {
16- 'interpolation-variable' : {
17- pattern : / ^ \$ \w [ \s \S ] * $ / ,
18- alias : 'variable'
19- } ,
20- 'interpolation-punctuation' : {
21- pattern : / ^ \$ { | } $ / ,
22- alias : 'punctuation'
23- } ,
24- 'interpolation-expression' : {
25- pattern : / [ \s \S ] + / ,
26- inside : Prism . languages . v
1+ ( function ( Prism ) {
2+ var interpolationExpr = {
3+ pattern : / [ \s \S ] + / ,
4+ inside : null
5+ } ;
6+
7+ Prism . languages . v = Prism . languages . extend ( 'clike' , {
8+ 'string' : [
9+ {
10+ pattern : / ` (?: \\ \` | \\ ? [ ^ \` ] { 1 , 2 } ) ` / , // using {1,2} instead of `u` flag for compatibility
11+ alias : 'rune'
12+ } ,
13+ {
14+ pattern : / r ? ( [ " ' ] ) (?: \\ (?: \r \n | [ \s \S ] ) | (? ! \1) [ ^ \\ \r \n ] ) * \1/ ,
15+ alias : 'quoted-string' ,
16+ greedy : true ,
17+ inside : {
18+ 'interpolation' : {
19+ pattern : / ( (?: ^ | [ ^ \\ ] ) (?: \\ { 2 } ) * ) \$ (?: \{ [ ^ { } ] * \} | \w + (?: \. \w + (?: \( [ ^ \( \) ] * \) ) ? | \[ [ ^ \[ \] ] + \] ) * ) / ,
20+ lookbehind : true ,
21+ inside : {
22+ 'interpolation-variable' : {
23+ pattern : / ^ \$ \w [ \s \S ] * $ / ,
24+ alias : 'variable'
25+ } ,
26+ 'interpolation-punctuation' : {
27+ pattern : / ^ \$ { | } $ / ,
28+ alias : 'punctuation'
29+ } ,
30+ 'interpolation-expression' : interpolationExpr
2731 }
2832 }
2933 }
3034 }
31- }
32- ] ,
33- 'class-name' : {
34- pattern : / ( \b (?: e n u m | i n t e r f a c e | s t r u c t | t y p e ) \s + ) \w + / ,
35- lookbehind : true
36- } ,
37- 'keyword' : / (?: \b (?: a s | a s m | a s s e r t | a t o m i c | b r e a k | c h a n | c o n s t | c o n t i n u e | d e f e r | e l s e | e m b e d | e n u m | f n | f o r | _ _ g l o b a l | g o (?: t o ) ? | i f | i m p o r t | i n | i n t e r f a c e | i s | l o c k | m a t c h | m o d u l e | m u t | n o n e | o r | p u b | r e t u r n | r l o c k | s e l e c t | s h a r e d | s i z e o f | s t a t i c | s t r u c t | t y p e (?: o f ) ? | u n i o n | u n s a f e ) | \$ (?: i f | e l s e | f o r ) | # (?: i n c l u d e | f l a g ) ) \b / ,
38- 'number' : / \b (?: 0 x [ a - f \d ] + (?: _ [ a - f \d ] + ) * | 0 b [ 0 1 ] + (?: _ [ 0 1 ] + ) * | 0 o [ 0 - 7 ] + (?: _ [ 0 - 7 ] + ) * | \d + (?: _ \d + ) * (?: \. \d + (?: _ \d + ) * ) ? ) \b / i,
39- 'operator' : / ~ | \? | [ * \/ % ^ ! = ] = ? | \+ [ = + ] ? | - [ = - ] ? | \| [ = | ] ? | & (?: = | & | \^ = ? ) ? | > (?: > = ? | = ) ? | < (?: < = ? | = | - ) ? | : = | \. \. \. ? / ,
40- 'builtin' : / \b (?: a n y (?: _ i n t | _ f l o a t ) ? | b o o l | b y t e (?: p t r ) ? | c h a r p t r | f (?: 3 2 | 6 4 ) | i (?: 8 | 1 6 | n t | 6 4 | 1 2 8 ) | r u n e | s i z e _ t | s t r i n g | u (?: 1 6 | 3 2 | 6 4 | 1 2 8 ) | v o i d p t r ) \b /
41- } ) ;
35+ ] ,
36+ 'class-name' : {
37+ pattern : / ( \b (?: e n u m | i n t e r f a c e | s t r u c t | t y p e ) \s + ) (?: C \. ) ? [ \w ] + / ,
38+ lookbehind : true
39+ } ,
40+ 'keyword' : / (?: \b (?: a s | a s m | a s s e r t | a t o m i c | b r e a k | c h a n | c o n s t | c o n t i n u e | d e f e r | e l s e | e m b e d | e n u m | f n | f o r | _ _ g l o b a l | g o (?: t o ) ? | i f | i m p o r t | i n | i n t e r f a c e | i s | l o c k | m a t c h | m o d u l e | m u t | n o n e | o r | p u b | r e t u r n | r l o c k | s e l e c t | s h a r e d | s i z e o f | s t a t i c | s t r u c t | t y p e (?: o f ) ? | u n i o n | u n s a f e ) | \$ (?: i f | e l s e | f o r ) | # (?: i n c l u d e | f l a g ) ) \b / ,
41+ 'number' : / \b (?: 0 x [ a - f \d ] + (?: _ [ a - f \d ] + ) * | 0 b [ 0 1 ] + (?: _ [ 0 1 ] + ) * | 0 o [ 0 - 7 ] + (?: _ [ 0 - 7 ] + ) * | \d + (?: _ \d + ) * (?: \. \d + (?: _ \d + ) * ) ? ) \b / i,
42+ 'operator' : / ~ | \? | [ * \/ % ^ ! = ] = ? | \+ [ = + ] ? | - [ = - ] ? | \| [ = | ] ? | & (?: = | & | \^ = ? ) ? | > (?: > = ? | = ) ? | < (?: < = ? | = | - ) ? | : = | \. \. \. ? / ,
43+ 'builtin' : / \b (?: a n y (?: _ i n t | _ f l o a t ) ? | b o o l | b y t e (?: p t r ) ? | c h a r p t r | f (?: 3 2 | 6 4 ) | i (?: 8 | 1 6 | n t | 6 4 | 1 2 8 ) | r u n e | s i z e _ t | s t r i n g | u (?: 1 6 | 3 2 | 6 4 | 1 2 8 ) | v o i d p t r ) \b /
44+ } ) ;
4245
43- Prism . languages . insertBefore ( 'v' , 'operator' , {
44- 'attribute' : {
45- pattern : / ^ \s * \[ (?: d e p r e c a t e d | u n s a f e _ f n | t y p e d e f | l i v e | i n l i n e | f l a g | r e f _ o n l y | w i n d o w s _ s t d c a l l | d i r e c t _ a r r a y _ a c c e s s ) \] / m,
46- alias : 'annotation' ,
47- inside : {
48- 'punctuation' : / [ \[ \] ] / ,
49- 'keyword' : / \w + /
50- }
51- } ,
52- 'generic' : {
53- pattern : / \< \w + \> (? = \s * [ \) \{ ] ) / ,
54- inside : {
55- 'punctuation' : / [ < > ] / ,
56- 'class-name' : / \w + /
46+ interpolationExpr . inside = Prism . languages . v ;
47+
48+ Prism . languages . insertBefore ( 'v' , 'operator' , {
49+ 'attribute' : {
50+ pattern : / ^ \s * \[ (?: d e p r e c a t e d | u n s a f e _ f n | t y p e d e f | l i v e | i n l i n e | f l a g | r e f _ o n l y | w i n d o w s _ s t d c a l l | d i r e c t _ a r r a y _ a c c e s s ) \] / m,
51+ alias : 'annotation' ,
52+ inside : {
53+ 'punctuation' : / [ \[ \] ] / ,
54+ 'keyword' : / \w + /
55+ }
56+ } ,
57+ 'generic' : {
58+ pattern : / \< \w + \> (? = \s * [ \) \{ ] ) / ,
59+ inside : {
60+ 'punctuation' : / [ < > ] / ,
61+ 'class-name' : / \w + /
62+ }
5763 }
58- }
59- } ) ;
60-
61- Prism . languages . insertBefore ( 'v' , ' function', {
62- 'generic-function' : {
63- // e.g. foo<T>( ...
64- pattern : / \w + \s * < \w + > (? = \( ) / ,
65- inside : {
66- 'function ' : / ^ \w + / ,
67- 'generic' : {
68- pattern : / < \w + > / ,
69- inside : Prism . languages . v . generic . inside
64+ } ) ;
65+
66+ Prism . languages . insertBefore ( 'v' , 'function' , {
67+ 'generic- function': {
68+ // e.g. foo<T>( ...
69+ pattern : / \w + \s * < \w + > (? = \( ) / ,
70+ inside : {
71+ 'function' : / ^ \w + / ,
72+ 'generic ' : {
73+ pattern : / < \w + > / ,
74+ inside : Prism . languages . v . generic . inside
75+ }
7076 }
7177 }
72- }
73- } ) ;
78+ } ) ;
79+ } ) ( Prism ) ;
0 commit comments