module Byebug::ParseFunctions

def get_int(str, cmd, min = nil, max = nil)


min or max is nil, that value has no bound.
Parse 'str' of command 'cmd' as an integer between min and max. If either
def get_int(str, cmd, min = nil, max = nil)
  if str !~ /\A[0-9]+\z/
    return nil, pr('parse.errors.int.not_number', cmd: cmd, str: str)
  end
  int = str.to_i
  if min && int < min
    return min, pr('parse.errors.int.too_low', cmd: cmd, str: str, min: min)
  elsif max && int > max
    return max, pr('parse.errors.int.too_high',
                   cmd: cmd, str: str, max: max)
  end
  int
end

def parse_steps(str, cmd)


is empty.
Returns the number of steps specified in as an integer or 1 if
def parse_steps(str, cmd)
  return 1 unless str
  steps, err = get_int(str, cmd, 1)
  return nil, err unless steps
  steps
end

def syntax_valid?(code)


Returns true if code is syntactically correct for Ruby.
def syntax_valid?(code)
  eval("BEGIN {return true}\n#{code}", nil, '', 0)
rescue SyntaxError
  false
end