File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,22 +88,30 @@ lp.readToken = function() {
8888}
8989
9090lp . resetTo = function ( pos ) {
91+ if ( this . options . locations ) {
92+ if ( pos >= this . toks . pos ) {
93+ let skipped = this . input . slice ( this . toks . pos , pos ) , match
94+ while ( match = lineBreakG . exec ( skipped ) ) {
95+ ++ this . toks . curLine
96+ this . toks . lineStart = match . index + match [ 0 ] . length
97+ }
98+ } else {
99+ this . toks . curLine = 1
100+ this . toks . lineStart = lineBreakG . lastIndex = 0
101+ let match
102+ while ( ( match = lineBreakG . exec ( this . input ) ) && match . index < pos ) {
103+ ++ this . toks . curLine
104+ this . toks . lineStart = match . index + match [ 0 ] . length
105+ }
106+ }
107+ }
108+
91109 this . toks . pos = pos
92110 this . toks . containsEsc = false
93111 let ch = this . input . charAt ( pos - 1 )
94112 this . toks . exprAllowed = ! ch || / [ [ { ( , ; : ? / * = + \- ~ ! | & % ^ < > ] / . test ( ch ) ||
95113 / [ e n w f d ] / . test ( ch ) &&
96114 / \b ( c a s e | e l s e | r e t u r n | t h r o w | n e w | i n | ( i n s t a n c e | t y p e ) ? o f | d e l e t e | v o i d ) $ / . test ( this . input . slice ( pos - 10 , pos ) )
97-
98- if ( this . options . locations ) {
99- this . toks . curLine = 1
100- this . toks . lineStart = lineBreakG . lastIndex = 0
101- let match
102- while ( ( match = lineBreakG . exec ( this . input ) ) && match . index < pos ) {
103- ++ this . toks . curLine
104- this . toks . lineStart = match . index + match [ 0 ] . length
105- }
106- }
107115}
108116
109117lp . lookAhead = function ( n ) {
You can’t perform that action at this time.
0 commit comments