@@ -181,7 +181,7 @@ object Parsers {
181181
182182/* -------------- TOKEN CLASSES ------------------------------------------- */
183183
184- def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
184+ def isIdent = in.isIdent
185185 def isIdent (name : Name ) = in.token == IDENTIFIER && in.name == name
186186 def isSimpleLiteral = simpleLiteralTokens contains in.token
187187 def isLiteral = literalTokens contains in.token
@@ -215,8 +215,7 @@ object Parsers {
215215 (allowedMods `contains` in.token) ||
216216 in.isSoftModifierInModifierPosition && ! excludedSoftModifiers.contains(in.name)
217217
218- def isStatSep : Boolean =
219- in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
218+ def isStatSep : Boolean = in.isNewLine || in.token == SEMI
220219
221220 /** A '$' identifier is treated as a splice if followed by a `{`.
222221 * A longer identifier starting with `$` is treated as a splice/id combination
@@ -341,10 +340,8 @@ object Parsers {
341340 /** semi = nl {nl} | `;'
342341 * nl = `\n' // where allowed
343342 */
344- def acceptStatSep (): Unit = in.token match {
345- case NEWLINE | NEWLINES => in.nextToken()
346- case _ => accept(SEMI )
347- }
343+ def acceptStatSep (): Unit =
344+ if in.isNewLine then in.nextToken() else accept(SEMI )
348345
349346 def acceptStatSepUnlessAtEnd (altEnd : Token = EOF ): Unit =
350347 if (! isStatSeqEnd)
@@ -603,9 +600,7 @@ object Parsers {
603600 val t = body()
604601 // Therefore, make sure there would be a matching <outdent>
605602 def nextIndentWidth = in.indentWidth(in.next.offset)
606- if (in.token == NEWLINE || in.token == NEWLINES )
607- && ! (nextIndentWidth < startIndentWidth)
608- then
603+ if in.isNewLine && ! (nextIndentWidth < startIndentWidth) then
609604 warning(
610605 if startIndentWidth <= nextIndentWidth then
611606 i """ Line is indented too far to the right, or a `{' is missing before:
@@ -623,7 +618,7 @@ object Parsers {
623618 * statement that's indented relative to the current region.
624619 */
625620 def checkNextNotIndented (): Unit = in.currentRegion match
626- case r : InBraces if in.token == NEWLINE || in.token == NEWLINES =>
621+ case r : InBraces if in.isNewLine =>
627622 val nextIndentWidth = in.indentWidth(in.next.offset)
628623 if r.indentWidth < nextIndentWidth then
629624 warning(i " Line is indented too far to the right, or a `{' is missing " , in.next.offset)
@@ -876,7 +871,7 @@ object Parsers {
876871 }
877872 if (lookahead.token == LARROW )
878873 false // it's a pattern
879- else if (lookahead.token != IDENTIFIER && lookahead.token != BACKQUOTED_IDENT )
874+ else if (lookahead.isIdent )
880875 true // it's not a pattern since token cannot be an infix operator
881876 else
882877 followedByToken(LARROW ) // `<-` comes before possible statement starts
@@ -904,7 +899,7 @@ object Parsers {
904899 */
905900 def followingIsGivenSig () =
906901 val lookahead = in.LookaheadScanner ()
907- if lookahead.token == IDENTIFIER || lookahead.token == BACKQUOTED_IDENT then
902+ if lookahead.isIdent then
908903 lookahead.nextToken()
909904 while lookahead.token == LPAREN || lookahead.token == LBRACKET do
910905 lookahead.skipParens()
@@ -1230,8 +1225,7 @@ object Parsers {
12301225 if (in.token == NEWLINE ) in.nextToken()
12311226
12321227 def newLinesOpt (): Unit =
1233- if (in.token == NEWLINE || in.token == NEWLINES )
1234- in.nextToken()
1228+ if in.isNewLine then in.nextToken()
12351229
12361230 def newLineOptWhenFollowedBy (token : Int ): Unit =
12371231 // note: next is defined here because current == NEWLINE
0 commit comments