Hi,

>
>   transform:
>   {
>       :result => {
>                 :term => "a"
>                   :plus => "+ ",
>                 :term=>"b"
>               }
>   }
>
>
> Any idea how to achieve that?
>

Closest I can get with a quick and dirty hack:

transform = Parslet::Transform.new do
    rule(:factor => simple(:str), :plus => simple(:str2), :term =>
simple(:str3)) do
        { term: str, plus: str2, term2: str3 }
    end

    rule(:term => subtree(:x)) { x}

end


There's probably a better way; matching a subtree() like that is usually not
a good idea, because of the epic scope for it going catastrophically wrong.

ant

Reply via email to