model_viewer: use a permalink to reach the old cardboard.jar
[nit.git] / contrib / nitcc / src / re2nfa.nit
index 6bca660..12cd600 100644 (file)
@@ -37,9 +37,8 @@ redef class Nstr
        redef fun make_rfa: Automaton
        do
                var a = new Automaton.epsilon
-               var val
                for c in self.value.chars do
-                       var b = new Automaton.atom(c.ascii)
+                       var b = new Automaton.atom(c.code_point)
                        a.concat(b)
                end
                return a
@@ -47,19 +46,19 @@ redef class Nstr
 end
 
 redef class Nch_dec
-       redef fun value: String do return text.substring_from(1).to_i.ascii.to_s
+       redef fun value: String do return text.substring_from(1).to_i.code_point.to_s
        redef fun make_rfa: Automaton
        do
-               var a = new Automaton.atom(self.value.chars.first.ascii)
+               var a = new Automaton.atom(self.value.chars.first.code_point)
                return a
        end
 end
 
 redef class Nch_hex
-       redef fun value: String do return text.substring_from(2).to_hex.ascii.to_s
+       redef fun value: String do return text.substring_from(2).to_hex.code_point.to_s
        redef fun make_rfa: Automaton
        do
-               var a = new Automaton.atom(self.value.chars.first.ascii)
+               var a = new Automaton.atom(self.value.chars.first.code_point)
                return a
        end
 end
@@ -174,6 +173,16 @@ redef class Nre_longest
        end
 end
 
+redef class Nre_prefixes
+       redef fun make_rfa
+       do
+               var a = children[2].make_rfa
+               a.trim
+               a.accept.add_all a.states
+               return a
+       end
+end
+
 redef class Nre_conc
        redef fun make_rfa
        do
@@ -224,11 +233,25 @@ redef class Nre_class
                var c1 = children[0].children[0].value
                var c2 = children[3].children[0].value
                if c1.length != 1 or c2.length != 1 then
-                       print "Classes only works on single char"
+                       print "Classes expect a single char"
+                       exit(1)
+                       abort
+               end
+               var a = new Automaton.cla(c1.chars.first.code_point, c2.chars.first.code_point)
+               return a
+       end
+end
+
+redef class Nre_openclass
+       redef fun make_rfa: Automaton
+       do
+               var c1 = children[0].children[0].value
+               if c1.length != 1 then
+                       print "Classes expect a single char"
                        exit(1)
                        abort
                end
-               var a = new Automaton.cla(c1.chars.first.ascii, c2.chars.first.ascii)
+               var a = new Automaton.cla(c1.chars.first.code_point, null)
                return a
        end
 end