lib/parser/ruby19.y in parser-2.4.0.0 vs lib/parser/ruby19.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
tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
@@ -19,11 +19,11 @@
tCHARACTER
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
@@ -682,18 +682,18 @@
}
| arg tPOW arg
{
result = @builder.binary_op(val[0], val[1], val[2])
}
- | tUMINUS_NUM tINTEGER tPOW arg
+ | tUNARY_NUM tINTEGER tPOW arg
{
result = @builder.unary_op(val[0],
@builder.binary_op(
@builder.integer(val[1]),
val[2], val[3]))
}
- | tUMINUS_NUM tFLOAT tPOW arg
+ | tUNARY_NUM tFLOAT tPOW arg
{
result = @builder.unary_op(val[0],
@builder.binary_op(
@builder.float(val[1]),
val[2], val[3]))
@@ -1764,18 +1764,28 @@
}
| tFLOAT
{
result = @builder.float(val[0])
}
- | tUMINUS_NUM tINTEGER =tLOWEST
+ | tUNARY_NUM tINTEGER =tLOWEST
{
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
+ num = @builder.integer(val[1])
+ if @builder.respond_to? :negate
+ # AST builder interface compatibility
+ result = @builder.negate(val[0], num)
+ else
+ result = @builder.unary_num(val[0], num)
+ end
}
- | tUMINUS_NUM tFLOAT =tLOWEST
+ | tUNARY_NUM tFLOAT =tLOWEST
{
- result = @builder.negate(val[0],
- @builder.float(val[1]))
+ num = @builder.float(val[1])
+ if @builder.respond_to? :negate
+ # AST builder interface compatibility
+ result = @builder.negate(val[0], num)
+ else
+ result = @builder.unary_num(val[0], num)
+ end
}
user_variable: tIDENTIFIER
{
result = @builder.ident(val[0])