nitdbg: Added an index parser returning the indexes of a range or int contained in...
authorLucas BAJOLET <r4pass@r4pass-ubu-laptophp.(none)>
Fri, 22 Feb 2013 19:03:39 +0000 (14:03 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 19 Mar 2013 18:04:05 +0000 (14:04 -0400)
Signed-off-by: Lucas BAJOLET <r4pass@hotmail.com>

src/debugger.nit

index cc6ed4f..c15963d 100644 (file)
@@ -464,6 +464,45 @@ class Debugger
                return null
        end
 
+       # Processes the indexes of a print array call
+       # Returns an array containing all the indexes demanded
+       fun process_index(index_string: String): nullable Array[Int]
+       do
+               var from_end_index = index_string.index_of('.')
+               var to_start_index = index_string.last_index_of('.')
+
+               if from_end_index != -1 and to_start_index != -1 then
+                       var index_from_string = index_string.substring(0,from_end_index)
+                       var index_to_string = index_string.substring_from(to_start_index+1)
+
+                       if index_from_string.is_numeric and index_to_string.is_numeric then
+                               var result_array = new Array[Int]
+
+                               var index_from = index_from_string.to_i
+                               var index_to = index_to_string.to_i
+
+                               for i in [index_from..index_to] do
+                                       result_array.push(i)
+                               end
+
+                               return result_array
+                       end
+               else
+                       if index_string.is_numeric
+                       then
+                               var result_array = new Array[Int]
+
+                               result_array.push(index_string.to_i)
+
+                               return result_array
+                       else
+                               return null
+                       end
+               end
+
+               return null
+       end
+
        #######################################################################
        ##                   Breakpoint placing functions                    ##
        #######################################################################