@@ -181,7 +181,7 @@ object Parsers {
181
181
182
182
/* -------------- TOKEN CLASSES ------------------------------------------- */
183
183
184
- def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
184
+ def isIdent = in.isIdent
185
185
def isIdent (name : Name ) = in.token == IDENTIFIER && in.name == name
186
186
def isSimpleLiteral = simpleLiteralTokens contains in.token
187
187
def isLiteral = literalTokens contains in.token
@@ -215,8 +215,7 @@ object Parsers {
215
215
(allowedMods `contains` in.token) ||
216
216
in.isSoftModifierInModifierPosition && ! excludedSoftModifiers.contains(in.name)
217
217
218
- def isStatSep : Boolean =
219
- in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
218
+ def isStatSep : Boolean = in.isNewLine || in.token == SEMI
220
219
221
220
/** A '$' identifier is treated as a splice if followed by a `{`.
222
221
* A longer identifier starting with `$` is treated as a splice/id combination
@@ -341,10 +340,8 @@ object Parsers {
341
340
/** semi = nl {nl} | `;'
342
341
* nl = `\n' // where allowed
343
342
*/
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 )
348
345
349
346
def acceptStatSepUnlessAtEnd (altEnd : Token = EOF ): Unit =
350
347
if (! isStatSeqEnd)
@@ -603,9 +600,7 @@ object Parsers {
603
600
val t = body()
604
601
// Therefore, make sure there would be a matching <outdent>
605
602
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
609
604
warning(
610
605
if startIndentWidth <= nextIndentWidth then
611
606
i """ Line is indented too far to the right, or a `{' is missing before:
@@ -623,7 +618,7 @@ object Parsers {
623
618
* statement that's indented relative to the current region.
624
619
*/
625
620
def checkNextNotIndented (): Unit = in.currentRegion match
626
- case r : InBraces if in.token == NEWLINE || in.token == NEWLINES =>
621
+ case r : InBraces if in.isNewLine =>
627
622
val nextIndentWidth = in.indentWidth(in.next.offset)
628
623
if r.indentWidth < nextIndentWidth then
629
624
warning(i " Line is indented too far to the right, or a `{' is missing " , in.next.offset)
@@ -876,7 +871,7 @@ object Parsers {
876
871
}
877
872
if (lookahead.token == LARROW )
878
873
false // it's a pattern
879
- else if (lookahead.token != IDENTIFIER && lookahead.token != BACKQUOTED_IDENT )
874
+ else if (lookahead.isIdent )
880
875
true // it's not a pattern since token cannot be an infix operator
881
876
else
882
877
followedByToken(LARROW ) // `<-` comes before possible statement starts
@@ -904,7 +899,7 @@ object Parsers {
904
899
*/
905
900
def followingIsGivenSig () =
906
901
val lookahead = in.LookaheadScanner ()
907
- if lookahead.token == IDENTIFIER || lookahead.token == BACKQUOTED_IDENT then
902
+ if lookahead.isIdent then
908
903
lookahead.nextToken()
909
904
while lookahead.token == LPAREN || lookahead.token == LBRACKET do
910
905
lookahead.skipParens()
@@ -1230,8 +1225,7 @@ object Parsers {
1230
1225
if (in.token == NEWLINE ) in.nextToken()
1231
1226
1232
1227
def newLinesOpt (): Unit =
1233
- if (in.token == NEWLINE || in.token == NEWLINES )
1234
- in.nextToken()
1228
+ if in.isNewLine then in.nextToken()
1235
1229
1236
1230
def newLineOptWhenFollowedBy (token : Int ): Unit =
1237
1231
// note: next is defined here because current == NEWLINE
0 commit comments