lib/parser/ruby23.y in parser-2.4.0.0 vs lib/parser/ruby23.y in parser-2.4.0.1

- old
+ new

@@ -5,11 +5,11 @@ kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__ k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT - tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ + tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY @@ -20,11 +20,11 @@ tRATIONAL tIMAGINARY tLABEL_END tANDDOT prechigh right tBANG tTILDE tUPLUS right tPOW - right tUMINUS_NUM tUMINUS + right tUNARY_NUM tUMINUS left tSTAR2 tDIVIDE tPERCENT left tPLUS tMINUS left tLSHFT tRSHFT left tAMPER2 left tPIPE tCARET @@ -687,11 +687,11 @@ } | arg tPOW arg { result = @builder.binary_op(val[0], val[1], val[2]) } - | tUMINUS_NUM simple_numeric tPOW arg + | tUNARY_NUM simple_numeric tPOW arg { result = @builder.unary_op(val[0], @builder.binary_op( val[1], val[2], val[3])) } @@ -1845,12 +1845,17 @@ numeric: simple_numeric { result = val[0] } - | tUMINUS_NUM simple_numeric =tLOWEST + | tUNARY_NUM simple_numeric =tLOWEST { - result = @builder.negate(val[0], val[1]) + if @builder.respond_to? :negate + # AST builder interface compatibility + result = @builder.negate(val[0], val[1]) + else + result = @builder.unary_num(val[0], val[1]) + end } simple_numeric: tINTEGER { result = @builder.integer(val[0])