def process_line(input, &output)
input.scan(line_regex)
if input[0] =~ /\A\s*(?:<[.]+>|[.]+)\s*\z/
puts "console: matched snip #{input[0].inspect}" if @debug
output_lexer.reset!
lang_lexer.reset!
yield Comment, input[0]
elsif prompt_regex =~ input[0]
puts "console: matched prompt #{input[0].inspect}" if @debug
output_lexer.reset!
yield Generic::Prompt, $&
$' =~ /\A\s*/
yield Text, $& unless $&.empty?
lang_lexer.lex($', continue: true, &output)
elsif comment_regex =~ input[0].strip
puts "console: matched comment #{input[0].inspect}" if @debug
output_lexer.reset!
lang_lexer.reset!
yield Comment, input[0]
else
puts "console: matched output #{input[0].inspect}" if @debug
lang_lexer.reset!
output_lexer.lex(input[0], continue: true, &output)
end
end