Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
~/NetBeansProjects/jruby ➔ cat fib.rb def self.fib(n) {n => :int, :return => :int} if (n < 2) n else fib(n - 2) + fib(n - 1) end end ~/NetBeansProjects/jruby ➔ jruby -rcompiler/duby -rjruby -e "n = JRuby.parse(File.read('fib.rb')); puts 'Normal AST:'; p n; puts 'Duby AST:'; new_ast = n.child_nodes[0].transform(nil); p new_ast" Normal AST: RootNode NewlineNode DefsNode |fib| SelfNode |self| ArgsNode BlockNode NewlineNode HashNode NewlineNode IfNode Duby AST: StaticMethodDefinition(fib) TypeReference(int, array = false) TypeReference(int, array = false) Arguments RequiredArgument(n) Body Noop If Call(<) Local(n) Fixnum(2) Local(n) Call(+) FunctionalCall(fib) Call(-) Local(n) Fixnum(2) FunctionalCall(fib) Call(-) Local(n) Fixnum(1)
Pasted March 19, 2008 2:48PM EDT
by headius
Channel #rubinius on irc.freenode.com
Embed