class IRB::Irb
def eval_input
def eval_input @scanner.set_prompt do |ltype, indent, continue, line_no| if ltype f = @context.prompt_s elsif continue f = @context.prompt_c elsif indent > 0 f = @context.prompt_n else f = @context.prompt_i end f = "" unless f if @context.prompting? @context.io.prompt = p = prompt(f, ltype, indent, line_no) else @context.io.prompt = p = "" end if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent) unless ltype prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i ind = prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size + indent * 2 - p.size ind += 2 if continue @context.io.prompt = p + " " * ind if ind > 0 end end @context.io.prompt end @scanner.set_input do signal_status(:IN_INPUT) do if l = @context.io.gets print l if @context.verbose? else if @context.ignore_eof? and @context.io.readable_after_eof? l = "\n" if @context.verbose? printf "Use \"exit\" to leave %s\n", @context.ap_name end else print "\n" if @context.prompting? end end l end end @scanner.configure_io(@context.io) @scanner.each_top_level_statement do |line, line_no| signal_status(:IN_EVAL) do begin # Assignment expression check should be done before evaluate_line to handle code like `a /2#/ if false; a = 1` is_assignment = assignment_expression?(line) evaluate_line(line, line_no) if @context.echo? if is_assignment if @context.echo_on_assignment? output_value(@context.echo_on_assignment? == :truncate) end else output_value end end rescue SystemExit, SignalException raise rescue Interrupt, Exception => exc handle_exception(exc) @context.workspace.local_variable_set(:_, exc) end end end end