app/controllers/preprocessor/python/augmentation.rb
# Parses a line starting at the given index under the assumption that the start index is not inside
# a string. Returns the index of the next character to be parsed. This method parses either until the
# end of the line is reached (in which case the returned index is equal to the line's length) or until
# it runs inside a string (in which case the returned index points to the string's first character).
#
# Note: This method expects to be called on a line that has had trailing whitespace removed.
Parses a line starting at the given index under the assumption that the start index is not inside
a string. Returns the index of the next character to be parsed. This method parses either until the
end of the line is reached (in which case the returned index is equal to the line's length) or until
it runs inside a string (in which case the returned index points to the string's first character).

This method expects to be called on a line that has had trailing whitespace removed.
Parses a line starting at the given index under the assumption that the start index is not inside a string . Returns the index of the next character to be parsed . This method parses either until the end of the line is reached ( in which case the returned index is equal to the line ' s length ) or until it runs inside a string ( in which case the returned index points to the string ' s first character ) . This method expects to be called on a line that has had trailing whitespace removed .
def parse_characters_normal(line, start_index)
    index = start_index
    while index < line.length
      if [ "(", "{", "[" ].include?(line[index])
        @state[:open_braces] += 1
        index += 1
      elsif [ ")", "}", "]" ].include?(line[index])
        @state[:open_braces] -= 1
        index += 1
      elsif line[index] == "#"
        index = line.length
      elsif line[index] == "\\" && index == line.length - 1
        @state[:line_continuator] = true
        index += 1
      elsif line[index] == '"""'
        @state[:in_string] = '"""'
        index += 3
        break
      elsif line[index] == "'''"
        @state[:in_string] = "'''"
        index += 3
        break
      elsif line[index] == '"'
        @state[:in_string] = '"'
        index += 1
        break
      elsif line[index] == "'"
        @state[:in_string] = "'"
        index += 1
        break
      else
        index += 1
      end
    end
    return index
  end
def parse_characters_normal ( line , start_index ) index = start_index while index < line . length if [ "(" , "{" , "[" ] . include? ( line [ index ] ) @state [ :open_braces ] += 1 index += 1 elsif [ ")" , "}" , "]" ] . include? ( line [ index ] ) @state [ :open_braces ] -= 1 index += 1 elsif line [ index ] == "#" index = line . length elsif line [ index ] == "\\" && index == line . length - 1 @state [ :line_continuator ] = true index += 1 elsif line [ index ] == '"""' @state [ :in_string ] = '"""' index += 3 break elsif line [ index ] == "'''" @state [ :in_string ] = "'''" index += 3 break elsif line [ index ] == '"' @state [ :in_string ] = '"' index += 1 break elsif line [ index ] == "'" @state [ :in_string ] = "'" index += 1 break else index += 1 end end return index end
Parses a line starting at the given index under the assumption that the start index is not inside
a string.
Parses a line starting at the given index under the assumption that the start index is not inside a string .
# Opening brace # Closing brace # We have found the start of a comment, so ignore the rest of the line # We have found a backslash as the last character -> line continuation # We have found a triple-quoted string. Advance index and leave # We have found a triple-quoted string. Advance index and leave # We have found a single-quoted string. Advance index and leave # We have found a single-quoted string. Advance index and leave # Advance a character
line
start_index