Help for this page

Select Code to Download


  1. or download this
    my %actions = 
       '*' => { $^a * $^b },
    ...
       '-' => { $^a - $^b };
    ...
    make %actions{$<op>.ast}.(|$/<lhs rhs>)
    
  2. or download this
    rule expression { <lhs=.numeric> <op> <rhs=.numeric> }
    
  3. or download this
    method numeric($/) { make +$/ }
    #                         ^  convert to a number
    ...
       }
       make $value;
    }
    
  4. or download this
    use v6;
    grammar Calc {
    ...
    say "$m<expression> =  $m.ast()";
    
    # vim: ft=perl6