Alexandre Mutel wrote:
> Damn, your solution was almost working well, but working on an external 
> file, the "eval" loose the step in the code

What do you mean by "loose the step" - it's reporting the wrong line 
number? I hacked together that code very quickly, and I'm sure it's 
fixable. Here is a more verbose version that is more likely to have the 
correct line number.

buf = nil
buf_line = 0
b = binding
src.each_with_index do |line,i|
  if line =~ /^(\w+):(.*)\n/
    label, code = $1, $2
    if buf
      eval buf, b, "DSL", buf_line+1
      buf = nil
    end
    eval "label(#{label.inspect}) { #{code}\n}", b, "DSL", i+1
  else
    unless buf
      buf = ""
      buf_line = i
    end
    buf << line
  end
end
if buf
  eval buf, b, "DSL", buf_line+1
  buf = nil
end
-- 
Posted via http://www.ruby-forum.com/.