Hello, I just started to play with Parslet, and I must say it is very intuitive. Coding a parser was a breeze, but I am having some trouble with the transform part.
I made a simple if else conditional parser, and I can't get the transform to
work.
Here the input:
'$if(foo)$ foo_block $elsif(bar)$ bar block $else$ baz $endif$'
And the parser result is:
{:text=>
[{:conditional=>
{:if_expression=>
{:condition=>{:attribute=>{:attribute_atom=>"foo"@4}},
:block=>" foo_block "@9},
:elsif_expression=>
[{:condition=>{:attribute=>{:attribute_atom=>"bar"@27}},
:block=>" bar block "@32}],
:else_expression=>{:block=>" baz "@49}}}]}
So far, so good.
I made a test rule to transform the :block value into some text
rule(:block => simple(:block) ){ "I am a block" }
And I got the following result
{:text=>
[{:conditional=>
{:if_expression=>{:condition=>nil, :block=>" foo_block "@9},
:elsif_expression=>[{:condition=>nil, :block=>" bar block "@32}],
:else_expression=>"I am a block"}}]}
Only the else_expression :block get transformed, what am I missing to have the
:elsif_expression :block and :if_expression :block also transformed?
Thanks in advance,
--
Eric Sagnes
サニエ エリック
signature.asc
Description: This is a digitally signed message part.
