updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Sun, 29 Oct 2023 00:06:30 +0100
changeset 947 dc31a099dc98
parent 946 bee7c57c18c3
child 948 6bb67c2dcfd3
updated
progs/lexer/lexer.sc
--- a/progs/lexer/lexer.sc	Sat Oct 28 21:00:11 2023 +0100
+++ b/progs/lexer/lexer.sc	Sun Oct 29 00:06:30 2023 +0100
@@ -39,16 +39,14 @@
   case c::Nil => CHAR(c)
   case c::s => SEQ(CHAR(c), charlist2rexp(s))
 }
+
 implicit def string2rexp(s : String) : Rexp = 
   charlist2rexp(s.toList)
 
+// to use & for records, instead of $ which had
+// its precedence be changed in Scala 3
 extension (s: String) {
-  def | (r: Rexp) = ALT(s, r)
-  def | (r: String) = ALT(s, r)
-  def % = STAR(s)
-  def ~ (r: Rexp) = SEQ(s, r)
-  def ~ (r: String) = SEQ(s, r)
-  def $ (r: Rexp) = RECD(s, r)
+  def & (r: Rexp) = RECD(s, r)
 }
 
 extension (r: Rexp) {
@@ -57,8 +55,6 @@
   def ~ (s: Rexp) = SEQ(r, s)
 }
 
-
-
 def nullable(r: Rexp) : Boolean = r match {
   case ZERO => false
   case ONE => true
@@ -213,14 +209,14 @@
 val STRING: Rexp = "\"" ~ SYM.% ~ "\""
 
 
-val WHILE_REGS = (("k" $ KEYWORD) | 
-                  ("i" $ ID) | 
-                  ("o" $ OP) | 
-                  ("n" $ NUM) | 
-                  ("s" $ SEMI) | 
-                  ("str" $ STRING) |
-                  ("p" $ (LPAREN | RPAREN)) | 
-                  ("w" $ WHITESPACE)).%
+val WHILE_REGS = (("k" & KEYWORD) | 
+                  ("i" & ID) | 
+                  ("o" & OP) | 
+                  ("n" & NUM) | 
+                  ("s" & SEMI) | 
+                  ("str" & STRING) |
+                  ("p" & (LPAREN | RPAREN)) | 
+                  ("w" & WHITESPACE)).%
 
 
 // Two Simple While Tests