22
33import { ParserStream } from './stream' ;
44import { ParseError } from './errors' ;
5+ import { includes } from './util' ;
6+
7+ const INLINE_WS = [ ' ' , '\t' ] ;
58
69export class FTLParserStream extends ParserStream {
7- peekLineWS ( ) {
10+ peekInlineWS ( ) {
811 let ch = this . currentPeek ( ) ;
912 while ( ch ) {
10- if ( ch !== ' ' && ch !== '\t' ) {
13+ if ( ! includes ( INLINE_WS , ch ) ) {
1114 break ;
1215 }
1316 ch = this . peek ( ) ;
1417 }
1518 }
1619
17- skipWSLines ( ) {
20+ skipBlankLines ( ) {
1821 while ( true ) {
19- this . peekLineWS ( ) ;
22+ this . peekInlineWS ( ) ;
2023
2124 if ( this . currentPeek ( ) === '\n' ) {
2225 this . skipToPeek ( ) ;
@@ -28,9 +31,9 @@ export class FTLParserStream extends ParserStream {
2831 }
2932 }
3033
31- skipLineWS ( ) {
34+ skipInlineWS ( ) {
3235 while ( this . ch ) {
33- if ( this . ch !== ' ' && this . ch !== '\t' ) {
36+ if ( ! includes ( INLINE_WS , this . ch ) ) {
3437 break ;
3538 }
3639 this . next ( ) ;
@@ -84,22 +87,6 @@ export class FTLParserStream extends ParserStream {
8487 return ( ( cc >= 48 && cc <= 57 ) || cc === 45 ) ; // 0-9
8588 }
8689
87- isPeekNextLineIndented ( ) {
88- if ( ! this . currentPeekIs ( '\n' ) ) {
89- return false ;
90- }
91-
92- this . peek ( ) ;
93-
94- if ( this . currentPeekIs ( ' ' ) ) {
95- this . resetPeek ( ) ;
96- return true ;
97- }
98-
99- this . resetPeek ( ) ;
100- return false ;
101- }
102-
10390 isPeekNextLineVariantStart ( ) {
10491 if ( ! this . currentPeekIs ( '\n' ) ) {
10592 return false ;
@@ -109,7 +96,7 @@ export class FTLParserStream extends ParserStream {
10996
11097 const ptr = this . getPeekIndex ( ) ;
11198
112- this . peekLineWS ( ) ;
99+ this . peekInlineWS ( ) ;
113100
114101 if ( this . getPeekIndex ( ) - ptr === 0 ) {
115102 this . resetPeek ( ) ;
@@ -137,7 +124,7 @@ export class FTLParserStream extends ParserStream {
137124
138125 const ptr = this . getPeekIndex ( ) ;
139126
140- this . peekLineWS ( ) ;
127+ this . peekInlineWS ( ) ;
141128
142129 if ( this . getPeekIndex ( ) - ptr === 0 ) {
143130 this . resetPeek ( ) ;
@@ -162,7 +149,7 @@ export class FTLParserStream extends ParserStream {
162149
163150 const ptr = this . getPeekIndex ( ) ;
164151
165- this . peekLineWS ( ) ;
152+ this . peekInlineWS ( ) ;
166153
167154 if ( this . getPeekIndex ( ) - ptr === 0 ) {
168155 this . resetPeek ( ) ;
@@ -191,7 +178,7 @@ export class FTLParserStream extends ParserStream {
191178
192179 const ptr = this . getPeekIndex ( ) ;
193180
194- this . peekLineWS ( ) ;
181+ this . peekInlineWS ( ) ;
195182
196183 if ( this . getPeekIndex ( ) - ptr === 0 ) {
197184 this . resetPeek ( ) ;
@@ -208,7 +195,7 @@ export class FTLParserStream extends ParserStream {
208195 }
209196
210197 skipToNextEntryStart ( ) {
211- while ( this . next ( ) ) {
198+ while ( this . ch ) {
212199 if ( this . currentIs ( '\n' ) && ! this . peekCharIs ( '\n' ) ) {
213200 this . next ( ) ;
214201 if ( this . ch === undefined || this . isIDStart ( ) ||
@@ -217,6 +204,7 @@ export class FTLParserStream extends ParserStream {
217204 break ;
218205 }
219206 }
207+ this . next ( ) ;
220208 }
221209 }
222210
0 commit comments