@@ -5,14 +5,14 @@ const keyValuePairPattern = /([-\w]+)=(?:'([^']*)'|"([^"]*)"|\`([^`]*)\`)/;
5
5
6
6
const WhiteSpace = createToken ( { name : "WhiteSpace" , pattern : / \s + / , group : Lexer . SKIPPED } ) ;
7
7
const Range0 = createToken ( { name : "Range0" , pattern : / \w * { \d + } / , label : "range" } ) ;
8
- const Range2Dotted = createToken ( { name : "Range2Dotted " , pattern : / \w * { \d + \. \. \d + } / , label : "range" } ) ;
8
+ const Range2 = createToken ( { name : "Range2 " , pattern : / \w * { \d + \. \. \d + } / , label : "range" } ) ;
9
9
const Ranges = createToken ( { name : "Ranges" , pattern : / \w * { (?: \d + | \d + \. \. \d + ) (?: , \s * (?: \d + | \d + \. \. \d + ) ) * } / , label : "range" } ) ;
10
10
const KeyValuePair = createToken ( { name : "KeyValuePair" , pattern : keyValuePairPattern , label : "pair" } ) ;
11
11
12
12
const tokens = [
13
13
WhiteSpace ,
14
14
Range0 ,
15
- Range2Dotted ,
15
+ Range2 ,
16
16
Ranges ,
17
17
KeyValuePair
18
18
] ;
@@ -53,14 +53,14 @@ export default class FenceParser {
53
53
switch ( type ) {
54
54
case "Range0" :
55
55
return { key, value : [ Number ( value ) ] , label } ;
56
- case "Range2Dotted " :
57
- const [ dottedB0 , dottedB1 ] = value . split ( ".." ) . map ( ( bound ) => Number ( bound ) ) ;
58
- const dottedRangeStart = Math . min ( dottedB0 , dottedB1 ) ;
59
- const dottedRangeStop = Math . max ( dottedB0 , dottedB1 ) ;
60
- const dottedRangeSize = dottedRangeStop - dottedRangeStart + 1 ;
56
+ case "Range2 " :
57
+ const [ b0 , b1 ] = value . split ( ".." ) . map ( ( bound ) => Number ( bound ) ) ;
58
+ const start = Math . min ( b0 , b1 ) ;
59
+ const stop = Math . max ( b0 , b1 ) ;
60
+ const size = stop - start + 1 ;
61
61
return {
62
62
key,
63
- value : Array . from ( { length : dottedRangeSize } , ( _ , i ) => i + dottedRangeStart ) ,
63
+ value : Array . from ( { length : size } , ( _ , i ) => i + start ) ,
64
64
label
65
65
} ;
66
66
case "Ranges" :
0 commit comments