diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2011-03-20 00:45:54 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2011-03-20 00:47:50 +0900 |
commit | 433e34c7f2c07aae003661c2e2182b68f03cbb67 (patch) | |
tree | 39fba3d384a8de72e6cd84dce9541caf57a35b63 | |
parent | d3a2ab840916f055f724c6c2cc5702cfccf160cd (diff) | |
download | erubis-433e34c7f2c07aae003661c2e2182b68f03cbb67.tar.gz |
[enhance] modify 'main.rb' to support Rubinius
-rw-r--r-- | lib/erubis/main.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/erubis/main.rb b/lib/erubis/main.rb index c8f1ff5..a2552bd 100644 --- a/lib/erubis/main.rb +++ b/lib/erubis/main.rb @@ -484,6 +484,32 @@ module Erubis 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 |