@@ -557,7 +557,7 @@ module TypeScript.Parser {
557
557
// when next requested.
558
558
while ( true ) {
559
559
// Parent must be a list or a node. All of those have a 'data' element.
560
- Debug . assert ( isNode ( parent ) || isList ( parent ) || isSeparatedList ( parent ) ) ;
560
+ Debug . assert ( isNode ( parent ) || isList ( parent ) ) ;
561
561
var dataElement = < { data : number } > < any > parent ;
562
562
if ( dataElement . data ) {
563
563
dataElement . data &= SyntaxConstants . NodeParsedInStrictModeMask
@@ -592,20 +592,6 @@ module TypeScript.Parser {
592
592
}
593
593
}
594
594
}
595
- else if ( isSeparatedList ( parent ) ) {
596
- var list2 = < ISyntaxNodeOrToken [ ] > parent ;
597
- for ( var i = 0 , n = list2 . childCount ( ) ; i < n ; i ++ ) {
598
- if ( list2 . childAt ( i ) === oldToken ) {
599
- if ( i % 2 === 0 ) {
600
- list2 [ i / 2 ] = newToken ;
601
- }
602
- else {
603
- list2 . separators [ ( i - 1 ) / 2 ] = newToken ;
604
- }
605
- return ;
606
- }
607
- }
608
- }
609
595
610
596
throw Errors . invalidOperation ( ) ;
611
597
}
@@ -3786,7 +3772,7 @@ module TypeScript.Parser {
3786
3772
return result ;
3787
3773
}
3788
3774
3789
- function parseSeparatedSyntaxList < T extends ISyntaxNodeOrToken > ( currentListType : ListParsingState , skippedTokens : ISyntaxToken [ ] ) : T [ ] {
3775
+ function parseSeparatedSyntaxList < T extends ISyntaxNodeOrToken > ( currentListType : ListParsingState , skippedTokens : ISyntaxToken [ ] ) : ISeparatedSyntaxList < T > {
3790
3776
var savedListParsingState = listParsingState ;
3791
3777
listParsingState |= ( 1 << currentListType ) ;
3792
3778
@@ -3799,7 +3785,7 @@ module TypeScript.Parser {
3799
3785
3800
3786
// Returns true if we should abort parsing.
3801
3787
function abortParsingListOrMoveToNextToken < T extends ISyntaxNodeOrToken > (
3802
- currentListType : ListParsingState , nodes : T [ ] , separators : ISyntaxToken [ ] , skippedTokens : ISyntaxToken [ ] ) : boolean {
3788
+ currentListType : ListParsingState , nodeAndSeparators : ISyntaxNodeOrToken [ ] , skippedTokens : ISyntaxToken [ ] ) : boolean {
3803
3789
// Ok. We're at a token that is not a terminator for the list and wasn't the start of
3804
3790
// an item in the list. Definitely report an error for this token.
3805
3791
reportUnexpectedTokenDiagnostic ( currentListType ) ;
@@ -3819,30 +3805,27 @@ module TypeScript.Parser {
3819
3805
3820
3806
// Otherwise, if none of the lists we're in can capture this token, then we need to
3821
3807
// unilaterally skip it. Note: we've already reported an error above.
3822
- addSkippedTokenToList ( nodes , separators , skippedTokens , consumeToken ( currentToken ( ) ) ) ;
3808
+ addSkippedTokenToList ( nodeAndSeparators , skippedTokens , consumeToken ( currentToken ( ) ) ) ;
3823
3809
3824
3810
// Continue parsing this list. Attach this token to whatever we've seen already.
3825
3811
return false ;
3826
3812
}
3827
3813
3828
- function addSkippedTokenToList < T extends ISyntaxNodeOrToken > (
3829
- nodes : T [ ] , separators : ISyntaxToken [ ] , skippedTokens : ISyntaxToken [ ] , skippedToken : ISyntaxToken ) : void {
3814
+ function addSkippedTokenToList (
3815
+ nodesAndSeparators : ISyntaxNodeOrToken [ ] , skippedTokens : ISyntaxToken [ ] , skippedToken : ISyntaxToken ) : void {
3830
3816
// Now, add this skipped token to the last item we successfully parsed in the list. Or
3831
3817
// add it to the list of skipped tokens if we haven't parsed anything. Our caller will
3832
3818
// have to deal with them.
3833
3819
//
3834
3820
// Note: we only bother doing this if we're creating a concrete syntax tree.
3835
3821
if ( syntaxFactory . isConcrete ) {
3836
- var length = nodes . length + ( separators ? separators . length : 0 ) ;
3822
+ var length = nodesAndSeparators . length ;
3837
3823
3838
3824
for ( var i = length - 1 ; i >= 0 ; i -- ) {
3839
- var array : ISyntaxNodeOrToken [ ] = separators && ( i % 2 === 1 ) ? separators : nodes ;
3840
- var arrayIndex = separators ? IntegerUtilities . integerDivide ( i , 2 ) : i ;
3841
-
3842
- var item = array [ arrayIndex ] ;
3825
+ var item = nodesAndSeparators [ i ] ;
3843
3826
var _lastToken = lastToken ( item ) ;
3844
3827
if ( _lastToken && _lastToken . fullWidth ( ) > 0 ) {
3845
- array [ arrayIndex ] = < T > addSkippedTokenAfterNodeOrToken ( item , skippedToken ) ;
3828
+ nodesAndSeparators [ i ] = addSkippedTokenAfterNodeOrToken ( item , skippedToken ) ;
3846
3829
return ;
3847
3830
}
3848
3831
}
@@ -3895,7 +3878,7 @@ module TypeScript.Parser {
3895
3878
3896
3879
// List wasn't complete and we didn't get an item. Figure out if we should bail out
3897
3880
// or skip a token and continue.
3898
- var abort = abortParsingListOrMoveToNextToken ( currentListType , items , /*separators:*/ undefined , skippedTokens ) ;
3881
+ var abort = abortParsingListOrMoveToNextToken ( currentListType , items , skippedTokens ) ;
3899
3882
if ( abort ) {
3900
3883
break ;
3901
3884
}
@@ -3914,9 +3897,8 @@ module TypeScript.Parser {
3914
3897
return result ;
3915
3898
}
3916
3899
3917
- function parseSeparatedSyntaxListWorker < T extends ISyntaxNodeOrToken > ( currentListType : ListParsingState , skippedTokens : ISyntaxToken [ ] ) : T [ ] {
3918
- var nodes : T [ ] = getArray ( ) ;
3919
- var separators : ISyntaxToken [ ] = getArray ( ) ;
3900
+ function parseSeparatedSyntaxListWorker < T extends ISyntaxNodeOrToken > ( currentListType : ListParsingState , skippedTokens : ISyntaxToken [ ] ) : ISeparatedSyntaxList < T > {
3901
+ var nodesAndSeparators : ISyntaxNodeOrToken [ ] = getArray ( ) ;
3920
3902
3921
3903
// Debug.assert(nodes.length === 0);
3922
3904
// Debug.assert(separators.length === 0);
@@ -3934,7 +3916,7 @@ module TypeScript.Parser {
3934
3916
// continue parsing.
3935
3917
3936
3918
// Debug.assert(oldItemsCount % 2 === 0);
3937
- var succeeded = tryParseExpectedListItem ( currentListType , inErrorRecovery , nodes , /*processItems:*/ undefined ) ;
3919
+ var succeeded = tryParseExpectedListItem ( currentListType , inErrorRecovery , nodesAndSeparators , /*processItems:*/ undefined ) ;
3938
3920
3939
3921
if ( ! succeeded ) {
3940
3922
// We weren't able to parse out a list element.
@@ -3948,7 +3930,7 @@ module TypeScript.Parser {
3948
3930
3949
3931
// List wasn't complete and we didn't get an item. Figure out if we should bail out
3950
3932
// or skip a token and continue.
3951
- var abort = abortParsingListOrMoveToNextToken ( currentListType , nodes , separators , skippedTokens ) ;
3933
+ var abort = abortParsingListOrMoveToNextToken ( currentListType , nodesAndSeparators , skippedTokens ) ;
3952
3934
if ( abort ) {
3953
3935
break ;
3954
3936
}
@@ -3973,7 +3955,7 @@ module TypeScript.Parser {
3973
3955
var tokenKind = _currentToken . kind ( ) ;
3974
3956
if ( tokenKind === _separatorKind || tokenKind === SyntaxKind . CommaToken ) {
3975
3957
// Consume the last separator and continue parsing list elements.
3976
- separators . push ( consumeToken ( _currentToken ) ) ;
3958
+ nodesAndSeparators . push ( consumeToken ( _currentToken ) ) ;
3977
3959
continue ;
3978
3960
}
3979
3961
@@ -4001,7 +3983,7 @@ module TypeScript.Parser {
4001
3983
4002
3984
if ( allowAutomaticSemicolonInsertion && canEatAutomaticSemicolon ( /*allowWithoutNewline:*/ false ) ) {
4003
3985
var semicolonToken = eatExplicitOrAutomaticSemicolon ( /*allowWithoutNewline:*/ false ) || Syntax . emptyToken ( SyntaxKind . SemicolonToken ) ;
4004
- separators . push ( semicolonToken ) ;
3986
+ nodesAndSeparators . push ( semicolonToken ) ;
4005
3987
// Debug.assert(items.length % 2 === 0);
4006
3988
continue ;
4007
3989
}
@@ -4011,7 +3993,7 @@ module TypeScript.Parser {
4011
3993
// This time mark that we're in error recovery mode though.
4012
3994
//
4013
3995
// Note: trying to eat this token will emit the appropriate diagnostic.
4014
- separators . push ( eatToken ( _separatorKind ) ) ;
3996
+ nodesAndSeparators . push ( eatToken ( _separatorKind ) ) ;
4015
3997
4016
3998
// Now that we're in 'error recovery' mode we cantweak some parsing rules as
4017
3999
// appropriate. For example, if we have:
@@ -4027,12 +4009,11 @@ module TypeScript.Parser {
4027
4009
inErrorRecovery = true ;
4028
4010
}
4029
4011
4030
- var result = Syntax . separatedList < T > ( nodes , separators ) ;
4012
+ var result = Syntax . separatedList < T > ( nodesAndSeparators ) ;
4031
4013
4032
4014
// Can't return if it has more then 0 elements. In that case, the list will have been
4033
4015
// copied into the SyntaxList.
4034
- returnZeroLengthArray ( nodes ) ;
4035
- returnZeroLengthArray ( separators ) ;
4016
+ returnZeroLengthArray ( nodesAndSeparators ) ;
4036
4017
4037
4018
return result ;
4038
4019
}
0 commit comments