progs/lexer/lexer.sc
changeset 944 f5d2453c5640
parent 943 5365ef60707e
child 945 5070392a1bd7
equal deleted inserted replaced
943:5365ef60707e 944:f5d2453c5640
   329 @main
   329 @main
   330 def all() = { small(); fib() ; loops() ; email() } 
   330 def all() = { small(); fib() ; loops() ; email() } 
   331 
   331 
   332 
   332 
   333 
   333 
   334 
   334 /*
   335 // runs with amm2 and amm3
   335 // Ammonite still provides 
   336 
   336 //
   337 
   337 //    scala.reflect.runtime.universe._
   338 
   338 //
       
   339 // which has been removed in Scala 3.
       
   340 //
       
   341 // for escaping strings in Scala 3
       
   342 import scala.quoted._
       
   343 
       
   344 def escapeImpl(raw: Expr[String])(using Quotes): Expr[String] = {
       
   345   import quotes.reflect.*
       
   346   Literal(StringConstant(raw.show)).asExprOf[String]
       
   347 }
       
   348 
       
   349 inline def esc(inline raw: String): String = ${escapeImpl('{raw})}
       
   350 
       
   351 val s = "abc\ndef"       // not escaped
       
   352 val e = esc("abc\ndef")  // escaped
       
   353 
       
   354 println(s)
       
   355 println(e)
       
   356 */