Hi,

I began using Parslet yesterday, and have been re-writing a Treetop parser
I wrote which parses certain HTTP headers according to the RFC. There's
been a few instances where I would like to preserve the tree at some level,
and only modify the parsed value.

Here's a gist to demonstrate:
https://gist.github.com/Wardrop/604f5ec38315e510ecff

Note that by default, none of the rules in the Transform apply, because
Parslet doesn't allow transformation of only the value component of of a
key/value pair. The commented out Transform rules show what I must do to
achieve the desired result. The problem with the commented out rule is that
it's repetitive. It no only requires me to redefine the inherit structure
of the tree, but it means if I had a larger parser where the `width` and
`height` parslets are used in many contexts (all of which require integer
conversion in the transform), I need to repeat myself even more.

My question is, does parslet allow any means of only transforming the value
of a key/value pair, preserving the key and the rest of the structure?

Tom

Reply via email to