model: intro `MModule::first_real_mmodule` to get the first non-fictive module
[nit.git] / contrib / nitcc / src / re2nfa.nit
index 1fa3cff..d0d90ac 100644 (file)
@@ -37,7 +37,6 @@ 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)
                        a.concat(b)
@@ -89,8 +88,17 @@ redef class Nre_minus
                var b = children[2].make_rfa.to_dfa
                for t in b.start.outs do
                        if not t.to.outs.is_empty then
-                               print "Not Yet Implemented Error: '-' only works on single char"
-                               exit(1)
+                               # `b` is not a single char, so just use except
+                               # "a - b == a Except (Any* b Any*)"
+                               var any1 = new Automaton.cla(0, null)
+                               any1.close
+                               var any2 = new Automaton.cla(0, null)
+                               any2.close
+                               var b2 = any1
+                               b2.concat(b)
+                               b2.concat(any2)
+                               var c = a.except(b2)
+                               return c
                        end
                        a.minus_sym(t.symbol.as(not null))
                end
@@ -98,6 +106,14 @@ redef class Nre_minus
        end
 end
 
+redef class Nre_end
+       redef fun make_rfa
+       do
+               print "{children.first.position.to_s}: NOT YET IMPLEMENTED: token `End`; replaced with an empty string"
+               return new Automaton.epsilon
+       end
+end
+
 redef class Nre_and
        redef fun make_rfa
        do