Created
September 3, 2021 06:59
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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