progs/lexer/lexer.sc
changeset 969 0dfa2923a7c6
parent 960 c7009356ddd8
child 970 1d4659dd83fe
--- a/progs/lexer/lexer.sc	Wed Oct 16 13:14:13 2024 +0100
+++ b/progs/lexer/lexer.sc	Fri Oct 18 05:45:14 2024 +0100
@@ -33,6 +33,7 @@
 case class Rec(x: String, v: Val) extends Val
    
 // some convenience for typing in regular expressions
+import scala.language.implicitConversions
 
 def charlist2rexp(s : List[Char]): Rexp = s match {
   case Nil => ONE
@@ -40,9 +41,7 @@
   case c::s => SEQ(CHAR(c), charlist2rexp(s))
 }
 
-implicit def string2rexp(s : String) : Rexp = 
-  charlist2rexp(s.toList)
-
+given Conversion[String, Rexp] = (s => charlist2rexp(s.toList))
 
 extension (s: String) {
   def $ (r: Rexp) = RECD(s, r)
@@ -239,8 +238,9 @@
 
 // escapes strings and prints them out as "", "\n" and so on
 def esc(raw: String): String = {
-  import scala.reflect.runtime.universe._
-  Literal(Constant(raw)).toString
+  raw
+  //import scala.reflect.runtime.universe._
+  //Literal(Constant(raw)).toString
 }
 
 def escape(tks: List[(String, String)]) =
@@ -344,4 +344,4 @@
 
 println(s)
 println(e)
-*/
\ No newline at end of file
+*/