--- a/progs/scala/re.scala Sat Nov 01 20:28:05 2014 +0000
+++ b/progs/scala/re.scala Sun Nov 02 12:24:41 2014 +0000
@@ -215,8 +215,8 @@
val BEGIN: Rexp = "{"
val END: Rexp = "}"
-/*
- * val WHILE_REGS = (("k" $ KEYWORD) |
+
+val WHILE_REGS = (("k" $ KEYWORD) |
("i" $ ID) |
("o" $ OP) |
("n" $ NUM) |
@@ -224,8 +224,8 @@
("p" $ (LPAREN | RPAREN)) |
("b" $ (BEGIN | END)) |
("w" $ WHITESPACE)).%
-*/
+/*
val WHILE_REGS = (KEYWORD |
ID |
OP |
@@ -234,7 +234,7 @@
LPAREN | RPAREN |
BEGIN | END |
WHITESPACE).%
-
+*/
// Some Tests
//============
@@ -247,14 +247,21 @@
result
}
+// Two Simple Tests
+//===================
+println("prog0 test")
+
val prog0 = """read n"""
-env (lexing(WHILE_REGS, prog0))
+println(env(lexing_simp(WHILE_REGS, prog0)))
-println("Next test")
-/*
+println("prog1 test")
+
val prog1 = """read n; write (n)"""
-env (lexing(WHILE_REGS, prog1))
+println(env(lexing_simp(WHILE_REGS, prog1)))
+
+// Big Test
+//==========
val prog2 = """
i := 2;
max := 100;
@@ -268,15 +275,12 @@
if isprime == 1 then write i else skip;
i := i + 1
}"""
-lexing_acc(WHILE_REGS, prog2)
+
+println("Tokens")
+println(env(lexing_simp(WHILE_REGS, prog2)))
-for (i <- 1 to 228 by 1) {
+for (i <- 1 to 80) {
print(i.toString + ": ")
- time(lexing_acc(WHILE_REGS, prog2 * i))
+ time(lexing_simp(WHILE_REGS, prog2 * i))
}
-for (i <- 1 to 100 by 10) {
- print(i.toString + ": ")
- time(lexing(WHILE_REGS, prog2 * i))
-}
-*/