diff -r dc31a099dc98 -r 6bb67c2dcfd3 progs/lexer/lex.sc --- a/progs/lexer/lex.sc Sun Oct 29 00:06:30 2023 +0100 +++ b/progs/lexer/lex.sc Sun Oct 29 13:05:09 2023 +0000 @@ -46,13 +46,10 @@ def ~ (s: Rexp) = SEQ(r, s) } +// 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) } val TEST = ("ab" | "ba").% @@ -166,20 +163,20 @@ 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)).% val KY : Rexp = "if" | "read" | "write" val WH : Rexp = " " | "\n" -val TRIV_REGS = (("k" $ KY) | - ("w" $ WHITESPACE)).% +val TRIV_REGS = (("k" & KY) | + ("w" & WHITESPACE)).% // Two Simple While Tests //======================== @@ -201,8 +198,3 @@ println(lexing(WHILE_REGS, prog2)) } - - - - -// runs with amm2 and amm3