@@ -321,30 +321,27 @@ object Scanners {
321
321
case _ =>
322
322
}
323
323
324
- /** Produce next token, filling TokenData fields of Scanner.
325
- */
326
- def nextToken (): Unit = {
327
- val lastToken = token
328
- adjustSepRegions(lastToken)
329
-
330
- // Read a token or copy it from `next` tokenData
331
- if (next.token == EMPTY ) {
324
+ /** Read a token or copy it from `next` tokenData */
325
+ private def getNextToken (lastToken : Token ): Unit =
326
+ if next.token == EMPTY then
332
327
lastOffset = lastCharOffset
333
- currentRegion match {
328
+ currentRegion match
334
329
case InString (multiLine, _) if lastToken != STRINGPART => fetchStringPart(multiLine)
335
330
case _ => fetchToken()
336
- }
337
- if (token == ERROR ) adjustSepRegions(STRINGLIT ) // make sure we exit enclosing string literal
338
- }
339
- else {
331
+ if token == ERROR then adjustSepRegions(STRINGLIT ) // make sure we exit enclosing string literal
332
+ else
340
333
this .copyFrom(next)
341
334
next.token = EMPTY
342
- }
343
335
344
- if (isAfterLineEnd) handleNewLine(lastToken)
336
+ /** Produce next token, filling TokenData fields of Scanner.
337
+ */
338
+ def nextToken (): Unit =
339
+ val lastToken = token
340
+ adjustSepRegions(lastToken)
341
+ getNextToken(lastToken)
342
+ if isAfterLineEnd then handleNewLine(lastToken)
345
343
postProcessToken()
346
344
printState()
347
- }
348
345
349
346
final def printState () =
350
347
if debugTokenStream && (showLookAheadOnDebug || ! isInstanceOf [LookaheadScanner ]) then
@@ -602,12 +599,10 @@ object Scanners {
602
599
insert(OUTDENT , offset)
603
600
case _ =>
604
601
605
- def lookAhead () = {
602
+ def lookAhead () =
606
603
prev.copyFrom(this )
607
- lastOffset = lastCharOffset
608
- fetchToken()
604
+ getNextToken(token)
609
605
if token == END && ! isEndMarker then token = IDENTIFIER
610
- }
611
606
612
607
def reset () = {
613
608
next.copyFrom(this )
0 commit comments