parser: use break and infinite loops
[nit.git] / src / parser / lexer.nit
index 3c0f81c..452d452 100644 (file)
@@ -41,15 +41,15 @@ redef class TComment
     end
 end
 
-redef class TKwpackage
+redef class TKwmodule
     redef fun parser_index: Int
     do
        return 2
     end
 
-    init init_tk(loc: Location)
+    init init_tk(text: String, loc: Location)
     do
-        _text = once "package"
+        _text = text
                _location = loc
     end
 end
@@ -1372,7 +1372,8 @@ special TablesCapable
                                                return new TComment.init_tk(token_text, location)
                                        end
                                        if accept_token == 3 then
-                                               return new TKwpackage.init_tk(location)
+                                               var token_text = text.substring(0, accept_length)
+                                               return new TKwmodule.init_tk(token_text, location)
                                        end
                                        if accept_token == 4 then
                                                return new TKwimport.init_tk(location)
@@ -1653,9 +1654,7 @@ special TablesCapable
                                        end
                                end
                        end
-                       if false then break # FIXME remove once unreach loop exits are in c_src
                end
-               return null # FIXME remove once unreach loop exits are in c_src
        end
 
        # Read the next character.