in src/main/scala/lang/Scanner.scala [22:39]
def joinStringTokens(tokens: List[Token]) = tokens.foldLeft(
List.empty[Token]
)((acc, token) => {
(acc.lastOption, token.tokenType) match {
case (Some(prevToken), TokenType.STRING)
if prevToken.tokenType == TokenType.STRING =>
acc.slice(0, acc.length - 1) :+ Token(
TokenType.STRING,
lexeme = prevToken.lexeme + " " + token.lexeme,
literal = Some(
prevToken.literal.getOrElse("") + " " + token.literal.getOrElse("")
),
prevToken.start,
token.end
)
case _ => acc :+ token
}
})