Parrot Compiler Tools Running Your Programming Language on Parrot #43

Sneak peek: transformation rules using NQP #1

transform past (ABC::Grammar::term) :language('PIR') {
    $S0 = node.'text'()
    .local pmc termpast
    termpast = new 'PAST::Val'
    termpast.'init'('node'=>node, 'name'=>$S0, 'vtype'=>'.Integer')
    .return (termpast)
}

becomes...

method term($/, $key) {
    return PAST::Val.new( node => $/,
                          name => ~$/,
                          vtype => '.Integer'
                        );
}
Copyright © 2007 chromatic and Patrick Michaud