--- a/progs/lexer/lexer.sc Sat Nov 11 10:08:33 2023 +0000
+++ b/progs/lexer/lexer.sc Fri Nov 17 20:06:43 2023 +0000
@@ -1,4 +1,4 @@
-// A simple lexer inspired by work of Sulzmann & Lu
+// A simple lexer inspired by work of Sulzmann $ Lu
//==================================================
//
// Call the test cases with
@@ -43,10 +43,9 @@
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) = RECD(s, r)
+ def $ (r: Rexp) = RECD(s, r)
}
extension (r: Rexp) {
@@ -60,7 +59,7 @@
case ONE => true
case CHAR(_) => false
case ALT(r1, r2) => nullable(r1) || nullable(r2)
- case SEQ(r1, r2) => nullable(r1) && nullable(r2)
+ case SEQ(r1, r2) => nullable(r1) $$ nullable(r2)
case STAR(_) => true
case RECD(_, r1) => nullable(r1)
}
@@ -209,14 +208,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