I have gone from being a Parslet transform n00b, weeping with
incomprehension, to a mad transforming zealot in the space of a couple of
days. I've now run out of things to Transform, so thought I'd raise a couple
of questions I had while I was learning this stuff.

Firstly, if I have a transform like this:

    rule(foo: sequence(:bar)) { some_method(bar) }

and some_method decides that, having examined 'bar', it doesn't actually
want to replace it after all, so it just returns 'bar'. ie no change.
However, from the Transformation's view point, this rule successfully
matched, so no further matches are attempted. For example, if I instead had:

    rule(foo: sequence(:bar)) { some_method(bar) }           # some_method()
returns 'bar' ie no change
    rule(foo: sequence(:bar)) { some_other_method(bar) }

then the second rule (and some_other_method()) never fire.

Is there some way to programmatically say, "this rule didn't match" ?
 Currently I wrap all these up in one single function, which is probably
more efficient anyway, but I'm curious.


Secondly, given that you can do this:

   rule( str('foo'), str('bar') ) { ...}

can you do something like this?

  rule(SomeClass, SomeOtherClass) {...}  # these classes are constructed by
earlier rules matching

I couldn't get it to work, but then decided that perhaps it's not meant to.

cheers

ant

Reply via email to