progs/cw1.scala
changeset 493 4e97783862ff
parent 492 39b7ff2cf1bc
child 547 81eb43c41416
equal deleted inserted replaced
492:39b7ff2cf1bc 493:4e97783862ff
   157 println("COMMENTS:")
   157 println("COMMENTS:")
   158 val ALL = CFUN((c:Char) => true)
   158 val ALL = CFUN((c:Char) => true)
   159 val COMMENT = "/*" ~ (NOT(ALL.% ~ "*/" ~ ALL.%)) ~ "*/"
   159 val COMMENT = "/*" ~ (NOT(ALL.% ~ "*/" ~ ALL.%)) ~ "*/"
   160 
   160 
   161 println(matcher(COMMENT, "/**/"))
   161 println(matcher(COMMENT, "/**/"))
   162 println(matcher(COMMENT, "/*foobar_comment*/"))
   162 println(matcher(COMMENT, "/*foobar*/"))
   163 println(matcher(COMMENT, "/*test*/test*/"))
   163 println(matcher(COMMENT, "/*test*/test*/"))
   164 println(matcher(COMMENT, "/*test/*test*/"))
   164 println(matcher(COMMENT, "/*test/*test*/"))
   165 
   165 
   166 println("EVILS:")
   166 println("EVILS:")
   167 val EVIL1 = PLUS(PLUS("a" ~ "a" ~ "a"))
   167 val EVIL1 = PLUS(PLUS("a" ~ "a" ~ "a"))
   180 println(matcher(EVIL2, "aaa" * 40))
   180 println(matcher(EVIL2, "aaa" * 40))
   181 println(matcher(EVIL2, "aaa" * 43 + "aa"))
   181 println(matcher(EVIL2, "aaa" * 43 + "aa"))
   182 println(matcher(EVIL2, "aaa" * 45 + "a"))
   182 println(matcher(EVIL2, "aaa" * 45 + "a"))
   183 
   183 
   184 println("TEST for bug pointed out by Filips Ivanovs")
   184 println("TEST for bug pointed out by Filips Ivanovs")
   185 val test = NMTIMES(RANGE(LOWERCASE + "."), 2, 6)
   185 val test = NMTIMES(CFUN(LOWERCASE | Set('.')), 2, 6)
   186   
   186   
   187 println(matcher(test,"a"))
   187 println(matcher(test,"a"))
   188 println(matcher(test,"ab"))
   188 println(matcher(test,"ab"))
   189 println(matcher(test,"abcdef"))
   189 println(matcher(test,"abcdef"))
   190 println(matcher(test,"abc"))
   190 println(matcher(test,"abc"))
   203 
   203 
   204 def TEST(s: String, r: Rexp) = {
   204 def TEST(s: String, r: Rexp) = {
   205   println("Rexp |" + s + "|")
   205   println("Rexp |" + s + "|")
   206   println("Derivative:\n" + ders_simp(s.toList, r))
   206   println("Derivative:\n" + ders_simp(s.toList, r))
   207   println("Is Nullable: " + nullable(ders_simp(s.toList, r)))
   207   println("Is Nullable: " + nullable(ders_simp(s.toList, r)))
   208   println("Is Zeroable: " + zeroable(ders_simp(s.toList, r)))
       
   209   Console.readLine
   208   Console.readLine
   210 }
   209 }
   211 
   210 
   212 
   211 
   213 val ALL2 = "a" | "f"
   212 val ALL2 = "a" | "f"