Skip to content

Instantly share code, notes, and snippets.

@aycabta
Created November 19, 2020 15:22
Show Gist options
  • Save aycabta/30ab96334275bced5796f118c9220b0b to your computer and use it in GitHub Desktop.
Save aycabta/30ab96334275bced5796f118c9220b0b to your computer and use it in GitHub Desktop.
start = Time.now
def each_top_level_statement
initialize_input
catch(:TERM_INPUT) do
loop do
begin
prompt
unless l = lex
throw :TERM_INPUT if @line == ''
else
@line_no += l.count("\n")
next if l == "\n"
@line.concat l
if @code_block_open or @ltype or @continue or @indent > 0
next
end
end
if @line != "\n"
@line.force_encoding(@io.encoding)
yield @line, @exp_line_no
end
break if @io.eof?
@line = ''
@exp_line_no = @line_no
@indent = 0
rescue TerminateLineInput
initialize_input
prompt
end
end
end
end
puts "Duration: #{Time.now - start} seconds"
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment