updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Wed, 25 Oct 2023 13:54:11 +0100
changeset 944 f5d2453c5640
parent 943 5365ef60707e
child 945 5070392a1bd7
updated
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