# HG changeset patch # User Christian Urban <christian.urban@kcl.ac.uk> # Date 1698238451 -3600 # Node ID f5d2453c56406ae75d4768e1c78e8b003ea3a1d6 # Parent 5365ef60707eaa587d30a4bc6be8093d1ec57819 updated diff -r 5365ef60707e -r f5d2453c5640 progs/lexer/lexer.sc --- a/progs/lexer/lexer.sc Sat Oct 21 09:09:09 2023 +0100 +++ b/progs/lexer/lexer.sc Wed Oct 25 13:54:11 2023 +0100 @@ -331,8 +331,26 @@ - -// runs with amm2 and amm3 +/* +// Ammonite still provides +// +// scala.reflect.runtime.universe._ +// +// which has been removed in Scala 3. +// +// for escaping strings in Scala 3 +import scala.quoted._ +def escapeImpl(raw: Expr[String])(using Quotes): Expr[String] = { + import quotes.reflect.* + Literal(StringConstant(raw.show)).asExprOf[String] +} +inline def esc(inline raw: String): String = ${escapeImpl('{raw})} +val s = "abc\ndef" // not escaped +val e = esc("abc\ndef") // escaped + +println(s) +println(e) +*/ \ No newline at end of file