@@ -94,12 +94,14 @@ export class LexedCssResult {
94
94
constructor ( public error : CssScannerError , public token : CssToken ) { }
95
95
}
96
96
97
- export function generateErrorMessage ( input , message , errorValue , index , row , column ) {
97
+ export function generateErrorMessage ( input : string , message : string , errorValue : string ,
98
+ index : number , row : number , column : number ) : string {
98
99
return `${ message } at column ${ row } :${ column } in expression [` +
99
100
findProblemCode ( input , errorValue , index , column ) + ']' ;
100
101
}
101
102
102
- export function findProblemCode ( input , errorValue , index , column ) {
103
+ export function findProblemCode ( input : string , errorValue : string , index : number ,
104
+ column : number ) : string {
103
105
var endOfProblemLine = index ;
104
106
var current = charCode ( input , index ) ;
105
107
while ( current > 0 && ! isNewline ( current ) ) {
@@ -163,7 +165,9 @@ export class CssScanner {
163
165
column : number = - 1 ;
164
166
line : number = 0 ;
165
167
168
+ /** @internal */
166
169
_currentMode : CssLexerMode = CssLexerMode . BLOCK ;
170
+ /** @internal */
167
171
_currentError : CssScannerError = null ;
168
172
169
173
constructor ( public input : string , private _trackComments : boolean = false ) {
@@ -196,7 +200,7 @@ export class CssScanner {
196
200
this . peekPeek = this . peekAt ( this . index + 1 ) ;
197
201
}
198
202
199
- peekAt ( index ) : number {
203
+ peekAt ( index : number ) : number {
200
204
return index >= this . length ? $EOF : StringWrapper . charCodeAt ( this . input , index ) ;
201
205
}
202
206
@@ -295,6 +299,7 @@ export class CssScanner {
295
299
return new LexedCssResult ( error , token ) ;
296
300
}
297
301
302
+ /** @internal */
298
303
_scan ( ) : CssToken {
299
304
var peek = this . peek ;
300
305
var peekPeek = this . peekPeek ;
@@ -348,7 +353,7 @@ export class CssScanner {
348
353
return this . error ( `Unexpected character [${ StringWrapper . fromCharCode ( peek ) } ]` ) ;
349
354
}
350
355
351
- scanComment ( ) {
356
+ scanComment ( ) : CssToken {
352
357
if ( this . assertCondition ( isCommentStart ( this . peek , this . peekPeek ) ,
353
358
"Expected comment start value" ) ) {
354
359
return null ;
@@ -375,7 +380,7 @@ export class CssScanner {
375
380
return new CssToken ( start , startingColumn , startingLine , CssTokenType . Comment , str ) ;
376
381
}
377
382
378
- scanWhitespace ( ) {
383
+ scanWhitespace ( ) : CssToken {
379
384
var start = this . index ;
380
385
var startingColumn = this . column ;
381
386
var startingLine = this . line ;
@@ -386,7 +391,7 @@ export class CssScanner {
386
391
return new CssToken ( start , startingColumn , startingLine , CssTokenType . Whitespace , str ) ;
387
392
}
388
393
389
- scanString ( ) {
394
+ scanString ( ) : CssToken {
390
395
if ( this . assertCondition ( isStringStart ( this . peek , this . peekPeek ) ,
391
396
"Unexpected non-string starting value" ) ) {
392
397
return null ;
@@ -416,7 +421,7 @@ export class CssScanner {
416
421
return new CssToken ( start , startingColumn , startingLine , CssTokenType . String , str ) ;
417
422
}
418
423
419
- scanNumber ( ) {
424
+ scanNumber ( ) : CssToken {
420
425
var start = this . index ;
421
426
var startingColumn = this . column ;
422
427
if ( this . peek == $PLUS || this . peek == $MINUS ) {
@@ -436,7 +441,7 @@ export class CssScanner {
436
441
return new CssToken ( start , startingColumn , this . line , CssTokenType . Number , strValue ) ;
437
442
}
438
443
439
- scanIdentifier ( ) {
444
+ scanIdentifier ( ) : CssToken {
440
445
if ( this . assertCondition ( isIdentifierStart ( this . peek , this . peekPeek ) ,
441
446
'Expected identifier starting value' ) ) {
442
447
return null ;
@@ -451,7 +456,7 @@ export class CssScanner {
451
456
return new CssToken ( start , startingColumn , this . line , CssTokenType . Identifier , strValue ) ;
452
457
}
453
458
454
- scanCssValueFunction ( ) {
459
+ scanCssValueFunction ( ) : CssToken {
455
460
var start = this . index ;
456
461
var startingColumn = this . column ;
457
462
while ( this . peek != $EOF && this . peek != $RPAREN ) {
@@ -461,7 +466,7 @@ export class CssScanner {
461
466
return new CssToken ( start , startingColumn , this . line , CssTokenType . Identifier , strValue ) ;
462
467
}
463
468
464
- scanCharacter ( ) {
469
+ scanCharacter ( ) : CssToken {
465
470
var start = this . index ;
466
471
var startingColumn = this . column ;
467
472
if ( this . assertCondition ( isValidCssCharacter ( this . peek , this . _currentMode ) ,
@@ -475,7 +480,7 @@ export class CssScanner {
475
480
return new CssToken ( start , startingColumn , this . line , CssTokenType . Character , c ) ;
476
481
}
477
482
478
- scanAtExpression ( ) {
483
+ scanAtExpression ( ) : CssToken {
479
484
if ( this . assertCondition ( this . peek == $AT , 'Expected @ value' ) ) {
480
485
return null ;
481
486
}
@@ -521,19 +526,19 @@ function isAtKeyword(current: CssToken, next: CssToken): boolean {
521
526
return current . numValue == $AT && next . type == CssTokenType . Identifier ;
522
527
}
523
528
524
- function isCharMatch ( target : number , previous : number , code : number ) {
529
+ function isCharMatch ( target : number , previous : number , code : number ) : boolean {
525
530
return code == target && previous != $BACKSLASH ;
526
531
}
527
532
528
533
function isDigit ( code : number ) : boolean {
529
534
return $0 <= code && code <= $9 ;
530
535
}
531
536
532
- function isCommentStart ( code : number , next : number ) {
537
+ function isCommentStart ( code : number , next : number ) : boolean {
533
538
return code == $SLASH && next == $STAR ;
534
539
}
535
540
536
- function isCommentEnd ( code : number , next : number ) {
541
+ function isCommentEnd ( code : number , next : number ) : boolean {
537
542
return code == $STAR && next == $SLASH ;
538
543
}
539
544
@@ -555,12 +560,12 @@ function isIdentifierStart(code: number, next: number): boolean {
555
560
target == $MINUS || target == $_ ;
556
561
}
557
562
558
- function isIdentifierPart ( target : number ) {
563
+ function isIdentifierPart ( target : number ) : boolean {
559
564
return ( $a <= target && target <= $z ) || ( $A <= target && target <= $Z ) || target == $BACKSLASH ||
560
565
target == $MINUS || target == $_ || isDigit ( target ) ;
561
566
}
562
567
563
- function isValidPseudoSelectorCharacter ( code : number ) {
568
+ function isValidPseudoSelectorCharacter ( code : number ) : boolean {
564
569
switch ( code ) {
565
570
case $LPAREN :
566
571
case $RPAREN :
@@ -570,11 +575,11 @@ function isValidPseudoSelectorCharacter(code: number) {
570
575
}
571
576
}
572
577
573
- function isValidKeyframeBlockCharacter ( code : number ) {
578
+ function isValidKeyframeBlockCharacter ( code : number ) : boolean {
574
579
return code == $PERCENT ;
575
580
}
576
581
577
- function isValidAttributeSelectorCharacter ( code : number ) {
582
+ function isValidAttributeSelectorCharacter ( code : number ) : boolean {
578
583
// value^*|$~=something
579
584
switch ( code ) {
580
585
case $$ :
@@ -589,7 +594,7 @@ function isValidAttributeSelectorCharacter(code: number) {
589
594
}
590
595
}
591
596
592
- function isValidSelectorCharacter ( code : number ) {
597
+ function isValidSelectorCharacter ( code : number ) : boolean {
593
598
// selector [ key = value ]
594
599
// IDENT C IDENT C IDENT C
595
600
// #id, .class, *+~>
@@ -610,7 +615,7 @@ function isValidSelectorCharacter(code: number) {
610
615
}
611
616
}
612
617
613
- function isValidStyleBlockCharacter ( code : number ) {
618
+ function isValidStyleBlockCharacter ( code : number ) : boolean {
614
619
// key:value;
615
620
// key:calc(something ... )
616
621
switch ( code ) {
@@ -630,7 +635,7 @@ function isValidStyleBlockCharacter(code: number) {
630
635
}
631
636
}
632
637
633
- function isValidMediaQueryRuleCharacter ( code : number ) {
638
+ function isValidMediaQueryRuleCharacter ( code : number ) : boolean {
634
639
// (min-width: 7.5em) and (orientation: landscape)
635
640
switch ( code ) {
636
641
case $LPAREN :
@@ -644,7 +649,7 @@ function isValidMediaQueryRuleCharacter(code: number) {
644
649
}
645
650
}
646
651
647
- function isValidAtRuleCharacter ( code : number ) {
652
+ function isValidAtRuleCharacter ( code : number ) : boolean {
648
653
// @document url(http://www.w3.org/page?something=on#hash),
649
654
switch ( code ) {
650
655
case $LPAREN :
@@ -668,7 +673,7 @@ function isValidAtRuleCharacter(code: number) {
668
673
}
669
674
}
670
675
671
- function isValidStyleFunctionCharacter ( code : number ) {
676
+ function isValidStyleFunctionCharacter ( code : number ) : boolean {
672
677
switch ( code ) {
673
678
case $PERIOD :
674
679
case $MINUS :
@@ -684,7 +689,7 @@ function isValidStyleFunctionCharacter(code: number) {
684
689
}
685
690
}
686
691
687
- function isValidBlockCharacter ( code : number ) {
692
+ function isValidBlockCharacter ( code : number ) : boolean {
688
693
// @something { }
689
694
// IDENT
690
695
return code == $AT ;
0 commit comments