In theory this is exactly what I want sadly I get a 

       wrong number of arguments (2 for 1)
     # 
/Users/jan/.rvm/gems/ruby-1.9.2-p290/gems/parslet-1.2.1/lib/parslet/transform.rb:136:in
 `apply'

Any idea?
Thanks.

Jan
On Sep 19, 2011, at 15:59 PM, Kaspar Schiess wrote:

>> Is it possible to somehow access information put on the transformer from the 
>> rules?
>> I need to supply information to the transformer on creation and then pass it 
>> on to every node that gets created in the rules.
>> Any ideas :)?
> 
> Hey,
> 
> I am not sure if I get this. But: Here's what your question makes me 
> think of: Say I have a context object that I want to pass around, like a 
> document I want to add all nodes into. Say also that I want to do this 
> in nice OOP-style, not using globals. Here's what you do:
> 
>   doc = Document.new
>   transform.apply(tree, :doc => doc)
> 
> and a rule in transform would look like:
> 
>   class MyTransform < Parslet::Transform
>     rule(SOMETHING) { doc.append Node.new }
>     rule(OROTHER)   { |d| d[:doc].append Node.new }
>   end
> 
> Does this help?
> 
> k
> 

Reply via email to