lib/processor.rb in rubyless-0.3.0 vs lib/processor.rb in rubyless-0.3.1
- old
+ new
@@ -10,12 +10,12 @@
module RubyLess
class RubyLessProcessor < SexpProcessor
attr_reader :ruby
- INFIX_OPERATOR = [:"<=>", :==, :<, :>, :<=, :>=, :-, :+, :*, :/, :%]
- PREFIX_OPERATOR = [:"-@"]
+ INFIX_OPERATOR = ['<=>', '==', '<', '>', '<=', '>=', '-', '+', '*', '/', '%']
+ PREFIX_OPERATOR = ['-@']
def self.translate(string, helper)
sexp = RubyParser.new.parse(string)
self.new(helper).process(sexp)
end
@@ -92,11 +92,11 @@
def process_vcall(exp)
var_name = exp.shift
unless opts = get_method([var_name], @helper, false)
raise "Unknown variable or method '#{var_name}'."
end
- method = opts[:method] || var_name.to_s
+ method = opts[:method]
t method, opts
end
def process_lit(exp)
lit = exp.shift
@@ -145,11 +145,11 @@
t true_res, opts
end
end
def method_call(receiver, exp)
- method = exp.shift
+ method = exp.shift.to_s
arg_sexp = args = exp.shift # rescue nil
if arg_sexp
args = process(arg_sexp)
if args == ''
signature = [method]
@@ -167,25 +167,25 @@
if receiver
if receiver.could_be_nil?
cond += receiver.cond
end
raise "'#{receiver}' does not respond to '#{method}(#{signature[1..-1].join(', ')})'." unless opts = get_method(signature, receiver.klass)
- method = opts[:method] if opts[:method]
- if method == :/
+ method = opts[:method]
+ if method == '/'
t_if cond, "(#{receiver.raw}#{method}#{args.raw} rescue nil)", opts.merge(:nil => true)
elsif INFIX_OPERATOR.include?(method)
t_if cond, "(#{receiver.raw}#{method}#{args.raw})", opts
elsif PREFIX_OPERATOR.include?(method)
t_if cond, "#{method.to_s[0..0]}#{receiver.raw}", opts
- elsif method == :[]
+ elsif method == '[]'
t_if cond, "#{receiver.raw}[#{args.raw}]", opts
else
args = "(#{args.raw})" if args != ''
t_if cond, "#{receiver.raw}.#{method}#{args}", opts
end
else
raise "Unknown method '#{method}(#{args.raw})'." unless opts = get_method(signature, @helper, false)
- method = opts[:method] if opts[:method]
+ method = opts[:method]
args = "(#{args.raw})" if args != ''
t_if cond, "#{method}#{args}", opts
end
end