On Mon, May 2, 2011 at 5:20 PM, Kaspar Schiess <[email protected]> wrote:
>
> Curiosity killed the cat ;) Have a look at parslet/pattern/binding.rb –
> The right way to do this IMHO is to create a binding that only matches
> the right kind of :bar!
>
Oh, interesting. How does it match a 'sequence()' directive in the transform
rule to a 'SequenceBind' object? Is it just string fu? Can I add a FooBind
object and start using 'foo()' in rules?
> No other way for saying: Hey I didn't match. Because.. in a way, once
> the block is executed, semantically parslet has a match.
>
Yeah that's what I figured, I wondered if there was any kind of "actually,
you know what....." undo mechanism.
> rule(SomeClass, SomeOtherClass) {...} # these classes are constructed
> Or are you looking for a generalized Ruby class hierarchy transformer?
> (Because I am ;))
Yeah, that one ;) I end up with a lot of entries like " [ #<IntegerLiteral:
0x....>, #<BinaryOperator: 0x....> ] " so what I do is match generic
sequences and figure out what to do in the transformation block. It would be
cool to be able to say:
rule(IntegerLiteral, BinaryOperator) {...}
cheers
ant
ant