Skip to content

Commit accd27d

Browse files
committed
Ruby compiler debug utility
1 parent dc69168 commit accd27d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ruby/bin/maps_debug_ruby_compile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env ruby
2+
ENV["INTERSCRIPT_STAGING"] = "1"
3+
require "bundler/setup"
4+
require "interscript"
5+
require "interscript/compiler/ruby"
6+
7+
# Compile a given map with the Ruby compiler for debugging purposes
8+
9+
if ARGV[0] == '-b'
10+
require 'base64'
11+
$b64 = true
12+
ARGV.shift
13+
end
14+
15+
map = ARGV[0]
16+
m = Interscript.parse(map)
17+
cr = Interscript::Compiler::Ruby
18+
mr = cr.(map)
19+
20+
if $b64
21+
puts Base64.encode64(mr.code)
22+
else
23+
puts mr.code
24+
end

ruby/bin/maps_debug_step_by_step

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mr = cr.(map, debug: true)
2121
m.tests.data.each_with_index do |(from, expected), idx|
2222
r = mr.(from)
2323

24-
unless ARGV[1] && ARGV[1].to_i == idx
24+
unless ARGV[1] && ARGV[1].split(",").any? { |i| i.to_i == idx }
2525
if r == expected
2626
cr.reset_debug_data
2727
next

0 commit comments

Comments
 (0)