Skip to content

Commit

Permalink
[enhance] modify 'main.rb' to support Rubinius
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatch committed Mar 19, 2011
1 parent d3a2ab8 commit 433e34c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/erubis/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,32 @@ def check_syntax(filename, src)
return "#{filename}:#{linenum}: #{message}"
end

if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
def check_syntax(filename, src)
require 'compiler'
verbose = $VERBOSE
msg = nil
begin
$VERBOSE = true
Rubinius::Compiler.compile_string(src, filename)
rescue SyntaxError => ex
ex_linenum = ex.line
linenum = 0
srcline = src.each_line do |line|
linenum += 1
break line if linenum == ex_linenum
end
msg = "#{ex.message}\n"
msg << srcline
msg << "\n" unless srcline =~ /\n\z/
msg << (" " * (ex.column-1)) << "^\n"
ensure
$VERBOSE = verbose
end
return msg
end
end

end

end

0 comments on commit 433e34c

Please sign in to comment.