@@ -323,14 +323,14 @@ export class Lexer {
323323 return yield * this . parseBlockStart ( )
324324 }
325325
326- private * parseBlockStart ( ) : Generator < string , 'doc' | null > {
326+ private * parseBlockStart ( ) : Generator < string , 'block-start' | ' doc' | null > {
327327 const [ ch0 , ch1 ] = this . peek ( 2 )
328328 if ( ! ch1 && ! this . atEnd ) return this . setNext ( 'block-start' )
329329 if ( ( ch0 === '-' || ch0 === '?' || ch0 === ':' ) && isEmpty ( ch1 ) ) {
330330 const n = ( yield * this . pushCount ( 1 ) ) + ( yield * this . pushSpaces ( true ) )
331331 this . indentNext = this . indentValue + 1
332332 this . indentValue += n
333- return yield * this . parseBlockStart ( )
333+ return 'block-start'
334334 }
335335 return 'doc'
336336 }
@@ -630,36 +630,34 @@ export class Lexer {
630630 }
631631
632632 private * pushIndicators ( ) : Generator < string , number > {
633- switch ( this . charAt ( 0 ) ) {
634- case '!' :
635- return (
636- ( yield * this . pushTag ( ) ) +
637- ( yield * this . pushSpaces ( true ) ) +
638- ( yield * this . pushIndicators ( ) )
639- )
640- case '&' :
641- return (
642- ( yield * this . pushUntil ( isNotAnchorChar ) ) +
643- ( yield * this . pushSpaces ( true ) ) +
644- ( yield * this . pushIndicators ( ) )
645- )
646- case '-' : // this is an error
647- case '?' : // this is an error outside flow collections
648- case ':' : {
649- const inFlow = this . flowLevel > 0
650- const ch1 = this . charAt ( 1 )
651- if ( isEmpty ( ch1 ) || ( inFlow && flowIndicatorChars . has ( ch1 ) ) ) {
652- if ( ! inFlow ) this . indentNext = this . indentValue + 1
653- else if ( this . flowKey ) this . flowKey = false
654- return (
655- ( yield * this . pushCount ( 1 ) ) +
656- ( yield * this . pushSpaces ( true ) ) +
657- ( yield * this . pushIndicators ( ) )
658- )
633+ let n = 0
634+ loop: while ( true ) {
635+ switch ( this . charAt ( 0 ) ) {
636+ case '!' :
637+ n += yield * this . pushTag ( )
638+ n += yield * this . pushSpaces ( true )
639+ continue loop
640+ case '&' :
641+ n += yield * this . pushUntil ( isNotAnchorChar )
642+ n += yield * this . pushSpaces ( true )
643+ continue loop
644+ case '-' : // this is an error
645+ case '?' : // this is an error outside flow collections
646+ case ':' : {
647+ const inFlow = this . flowLevel > 0
648+ const ch1 = this . charAt ( 1 )
649+ if ( isEmpty ( ch1 ) || ( inFlow && flowIndicatorChars . has ( ch1 ) ) ) {
650+ if ( ! inFlow ) this . indentNext = this . indentValue + 1
651+ else if ( this . flowKey ) this . flowKey = false
652+ n += yield * this . pushCount ( 1 )
653+ n += yield * this . pushSpaces ( true )
654+ continue loop
655+ }
659656 }
660657 }
658+ break loop
661659 }
662- return 0
660+ return n
663661 }
664662
665663 private * pushTag ( ) {
0 commit comments