@@ -29,7 +29,7 @@ export function parse(content: string) {
29
29
30
30
const options : Option [ ] = [ ] ;
31
31
const succeeds = new Set < number > ( ) ;
32
- const errors : Array < { name : string ; start : number } > = [ ] ;
32
+ const errors : Array < { name : string ; start : number ; block : string } > = [ ] ;
33
33
let last = - 1 ;
34
34
for ( const match of content . matchAll ( / \* ' ( \w + ) ' \* / g) ) {
35
35
const name = match [ 1 ] ;
@@ -45,17 +45,20 @@ export function parse(content: string) {
45
45
succeeds . add ( start ) ;
46
46
last = end ;
47
47
} else {
48
- errors . push ( { name, start } ) ;
48
+ errors . push ( { name, start, block } ) ;
49
49
}
50
50
}
51
51
52
52
if ( errors . length ) {
53
- for ( const { name, start } of errors ) {
53
+ for ( const { name, start, block } of errors ) {
54
54
if ( ! succeeds . has ( start ) ) {
55
55
const line = content . substring ( 0 , start + 1 ) . split ( "\n" ) . length ;
56
56
console . error (
57
- `Failed to parse option definition for ${ name } at line ${ line } ` ,
57
+ `Failed to parse option definition for ' ${ name } ' at line ${ line } : ` ,
58
58
) ;
59
+ console . error ( "----- block start -----" ) ;
60
+ console . error ( block ) ;
61
+ console . error ( "----- block end -----" ) ;
59
62
}
60
63
}
61
64
}
@@ -107,7 +110,8 @@ function parseBlock(name: string, body: string): Option | undefined {
107
110
const reTags = / (?: [ \t ] + \* [ ^ * \s ] + \* ) + [ \t ] * $ / . source ;
108
111
const reShortNames = / (?: [ \t ] + ' \w + ' ) * / . source ;
109
112
const reType = / [ \t ] + (?< type > \w + ) / . source ;
110
- const reDefaults = / [ \t ] + (?< defaults > \( .* ?(?: \n \t { 3 , } [ \t ] .* ?) * ?\) ) / . source ;
113
+ const reDefaults =
114
+ / [ \t ] + (?< defaults > \( .* ?(?: \n (?: \t { 3 , } | { 24 , } ) [ \t ] .* ?) * ?\) ) / . source ;
111
115
const reDefinition =
112
116
`^'${ name } '${ reShortNames } (?:${ reType } (?:${ reDefaults } )?)?(?:${ reTags } )?$` ;
113
117
const m1 = body . match ( new RegExp ( reDefinition , "dm" ) ) ;
0 commit comments