Skip to content

Instantly share code, notes, and snippets.

@iacore
Created September 3, 2021 06:59
Show Gist options
  • Save iacore/307794ef0364321db1b8c67c9c38bc01 to your computer and use it in GitHub Desktop.
Save iacore/307794ef0364321db1b8c67c9c38bc01 to your computer and use it in GitHub Desktop.
why3 file line number rewrite (to be used with vscode or other ide)
#!/usr/bin/env ruby
def rewrite(rd, wr)
rd.each do |line|
line = line.gsub /File "(.*)", line (\d+), characters (\d+)-(\d+):/, 'File \1:\2:\3 to \4'
wr.puts line
# wr.flush
end
end
if $0 == __FILE__
out_rd, out_wr = IO.pipe
err_rd, err_wr = IO.pipe
pid = spawn("why3", *ARGV, :out => out_wr, :err => err_wr)
thr_out_rewrite = Thread.new { rewrite(out_rd, STDOUT) }
thr_err_rewrite = Thread.new { rewrite(err_rd, STDERR) }
Process.wait pid
thr_out_rewrite.kill
thr_err_rewrite.kill
out_rd.close
out_wr.close
err_rd.close
err_wr.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment