lib/junoser/transformer.rb in junoser-0.1.2 vs lib/junoser/transformer.rb in junoser-0.1.3

- old
+ new

@@ -21,21 +21,35 @@ rule(label: simple(:label), child: simple(:child)) do "#{label}\n#{child}" end rule(label: simple(:label), child: sequence(:children)) do + Junoser::Transformer.remove_slash_asterisk children %[#{label}\n#{children.join("\n")}] end rule(statement: simple(:statement), argument: simple(:argument)) do "#{statement} #{argument}" end rule(statement: simple(:statement), argument: sequence(:arguments)) do + Junoser::Transformer.remove_slash_asterisk arguments %[#{statement}\n#{arguments.join("\n")}] end rule(oneline: simple(:str)) do - str.gsub "\n", ' ' + str.to_s.gsub("\n", ' ') + end + + + def self.remove_slash_asterisk(array) + open = array.index("arg(/*)\n") + close = array.index("arg(*/)") + + if open && close + (open..close).reverse_each do |i| + array.delete_at i + end + end end end end