--- a/progs/scala/re-ext.scala Sat Mar 04 22:27:09 2017 +0000
+++ b/progs/scala/re-ext.scala Sun Mar 05 00:31:04 2017 +0000
@@ -249,15 +249,14 @@
// Lexing Rules
-def PLUSs(r: Rexp) = r ~ r.%
-val SYM = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
-val DIGIT = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+val SYM = CHARS ("abcdefghijklmnopqrstuvwxyz" contains _)
+val DIGIT = CHARS("0123456789" contains _)
val ID = SYM ~ (SYM | DIGIT).%
-val NUM = PLUSs(DIGIT)
+val NUM = PLUS(DIGIT)
val KEYWORD : Rexp = "skip" | "while" | "do" | "if" | "then" | "else" | "read" | "write" | "true" | "false"
val SEMI: Rexp = ";"
val OP: Rexp = ":=" | "==" | "-" | "+" | "*" | "!=" | "<" | ">" | "<=" | ">=" | "%" | "/"
-val WHITESPACE = PLUSs(" " | "\n" | "\t")
+val WHITESPACE = PLUS(" " | "\n" | "\t")
val RPAREN: Rexp = ")"
val LPAREN: Rexp = "("
val BEGIN: Rexp = "{"
@@ -336,12 +335,12 @@
println("prog3 test - tokens")
println(env(lexing_simp(WHILE_REGS, prog3)))
-/*
-for (i <- 1 to 80) {
- print(i.toString + ": ")
- time(lexing_simp(WHILE_REGS, prog2 * i))
+println("prog2 replicated test")
+
+for (i <- 1 to 88) {
+ println(i + ": " + "%.5f".format(time_needed(2, lexing_simp(WHILE_REGS, prog2 * i))))
}
-*/
+
// Sulzmann's tests
//==================