@@ -321,30 +321,27 @@ object Scanners {
321321 case _ =>
322322 }
323323
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
332327 lastOffset = lastCharOffset
333- currentRegion match {
328+ currentRegion match
334329 case InString (multiLine, _) if lastToken != STRINGPART => fetchStringPart(multiLine)
335330 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
340333 this .copyFrom(next)
341334 next.token = EMPTY
342- }
343335
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)
345343 postProcessToken()
346344 printState()
347- }
348345
349346 final def printState () =
350347 if debugTokenStream && (showLookAheadOnDebug || ! isInstanceOf [LookaheadScanner ]) then
@@ -602,12 +599,10 @@ object Scanners {
602599 insert(OUTDENT , offset)
603600 case _ =>
604601
605- def lookAhead () = {
602+ def lookAhead () =
606603 prev.copyFrom(this )
607- lastOffset = lastCharOffset
608- fetchToken()
604+ getNextToken(token)
609605 if token == END && ! isEndMarker then token = IDENTIFIER
610- }
611606
612607 def reset () = {
613608 next.copyFrom(this )
0 commit comments