Index: t/00-parrot/10-augop.t =================================================================== --- t/00-parrot/10-augop.t (revision 0) +++ t/00-parrot/10-augop.t (revision 0) @@ -0,0 +1,48 @@ +#!./parrot pynie.pbc + +# check augmented assignment ops +print '1..11' + +i = 0 +i += 10 +if i == 10: print 'ok 1' + +i = 10 +i -= 5 +if i == 5: print 'ok 2' + +i = -5 +i *= 2 +if i == -10: print 'ok 3' + +i = 10 +i /= 2 +if i == 5: print 'ok 4' + +i = 10 +i %= 4 +if i == 2: print 'ok 5' + +i = 3 +i **= 3 +if i == 27: print 'ok 6' + +i = 128 +i >>= 2 +if i == 32: print 'ok 7' + +i = 1 +i <<= 10 +if i == 1024: print 'ok 8' + +i = 0x55 +i &= 0x1f +if i == 0x15: print 'ok 9' + +i = 0x55 +i ^= 0x1f +if i == 0x4a: print 'ok 10' + +i = 0x55 +i |= 0x1f +if i == 0x5f: print 'ok 11' Index: src/parser/Grammar.pg =================================================================== --- src/parser/Grammar.pg (revision 31237) +++ src/parser/Grammar.pg (working copy) @@ -225,7 +225,7 @@ token simple_stmt { | {*} #= assert_stmt | {*} #= assignment_stmt - | + | {*} #= augmented_assignment_stmt | {*} #= expression_stmt | {*} #= pass_stmt | {*} #= del_stmt @@ -254,7 +254,10 @@ {*} } -rule augmented_assignment_stmt { } +rule augmented_assignment_stmt { + + {*} +} rule target_list { [ ',' ]* ','? @@ -504,7 +507,17 @@ } token augop { - $=['+='|'-='|'*='|'/='|'\%='|'**='|'>>='|'<<='|'&='|'^='|'|='] + | '+=' {*} #= add + | '-=' {*} #= sub + | '*=' {*} #= mul + | '/=' {*} #= div + | '\%=' {*} #= mod +# | '**=' {*} #= pow + | '>>=' {*} #= shr + | '<<=' {*} #= shl + | '&=' {*} #= band + | '^=' {*} #= bxor + | '|=' {*} #= bor } rule primary { Index: src/parser/Actions.pm =================================================================== --- src/parser/Actions.pm (revision 31237) +++ src/parser/Actions.pm (working copy) @@ -573,6 +573,17 @@ make $past; } +method augop($/, $key) { + make PAST::Op.new( :pirop($key), :node($/) ); +} + +method augmented_assignment_stmt($/) { + my $past := $($); + $past.push( $($) ); + $past.push( $($) ); + make $past; +} + method target_list($/) { my $past := PAST::VarList.new( :node($/) ); for $ {