lib/rbs/parser.y in rbs-0.7.0 vs lib/rbs/parser.y in rbs-0.8.0

- old
+ new

@@ -2,13 +2,13 @@ token tUIDENT tLIDENT tNAMESPACE tINTERFACEIDENT tLKEYWORD tUKEYWORD tGLOBALIDENT tIVAR tCLASSVAR tANNOTATION tSTRING tSYMBOL tINTEGER tWRITE_ATTR kLPAREN kRPAREN kLBRACKET kRBRACKET kLBRACE kRBRACE - kVOID kNIL kTRUE kFALSE kANY kUNTYPED kTOP kBOT kSELF kSELFQ kINSTANCE kCLASS kBOOL kSINGLETON kTYPE kDEF kMODULE kSUPER + kVOID kNIL kTRUE kFALSE kANY kUNTYPED kTOP kBOT kSELF kSELFQ kINSTANCE kCLASS kBOOL kSINGLETON kTYPE kDEF kMODULE kPRIVATE kPUBLIC kALIAS - kCOLON kCOLON2 kCOMMA kBAR kAMP kHAT kARROW kQUESTION kEXCLAMATION kSTAR kSTAR2 kFATARROW kEQ kDOT kLT + kCOLON kCOLON2 kCOMMA kBAR kAMP kHAT kARROW kQUESTION kEXCLAMATION kSTAR kSTAR2 kFATARROW kEQ kDOT kDOT3 kLT kINTERFACE kEND kINCLUDE kEXTEND kATTRREADER kATTRWRITER kATTRACCESSOR tOPERATOR tQUOTEDMETHOD tQUOTEDIDENT kPREPEND kEXTENSION kINCOMPATIBLE type_TYPE type_SIGNATURE type_METHODTYPE tEOF kOUT kIN kUNCHECKED kOVERLOAD @@ -423,11 +423,16 @@ annotations: val[0], location: location, comment: leading_comment(val[0].first&.location || location)) } - overload: { result = nil } | kOVERLOAD + overload: + { result = nil } + | kOVERLOAD { + RBS.logger.warn "`overload def` syntax is deprecated. Use `...` syntax instead." + result = val[0] + } method_member: annotations attributes overload kDEF method_kind def_name method_types { location = val[3].location + val[6].last.location types = val[6].map do |type| @@ -436,19 +441,28 @@ type.value else type end end + + last_type = val[6].last + if last_type.is_a?(LocatedValue) && last_type.value == :dot3 + overload = true + val[6].pop + else + overload = false + end + result = Members::MethodDefinition.new( name: val[5].value, kind: val[4], - types: types, + types: val[6], annotations: val[0], location: location, comment: leading_comment(val[0].first&.location || val[1].first&.location || val[2]&.location || val[3].location), attributes: val[1].map(&:value), - overload: !!val[2] + overload: overload || !!val[2] ) } attributes: { result = [] } @@ -461,11 +475,11 @@ | kSELF kDOT { result = :singleton } | kSELFQ kDOT { result = :singleton_instance } method_types: method_type { result = [val[0]] } - | kSUPER { result = [LocatedValue.new(value: :super, location: val[0].location)] } + | kDOT3 { result = [LocatedValue.new(value: :dot3, location: val[0].location)] } | method_type kBAR method_types { result = val[2].unshift(val[0]) } method_type: @@ -546,11 +560,11 @@ identifier_keywords: kCLASS | kVOID | kNIL | kTRUE | kFALSE | kANY | kUNTYPED | kTOP | kBOT | kINSTANCE | kBOOL | kSINGLETON | kTYPE | kMODULE | kPRIVATE | kPUBLIC | kEND | kINCLUDE | kEXTEND | kPREPEND | kATTRREADER | kATTRACCESSOR | kATTRWRITER | kDEF | kEXTENSION | kSELF | kINCOMPATIBLE - | kUNCHECKED | kINTERFACE | kSUPER | kALIAS | kOUT | kIN | kOVERLOAD + | kUNCHECKED | kINTERFACE | kALIAS | kOUT | kIN | kOVERLOAD module_type_params: { result = nil } | kLBRACKET module_type_params0 kRBRACKET { val[1].each {|p| insert_bound_variable(p.name) } @@ -1216,11 +1230,10 @@ "prepend" => :kPREPEND, "module" => :kMODULE, "attr_reader" => :kATTRREADER, "attr_writer" => :kATTRWRITER, "attr_accessor" => :kATTRACCESSOR, - "super" => :kSUPER, "public" => :kPUBLIC, "private" => :kPRIVATE, "alias" => :kALIAS, "extension" => :kEXTENSION, "incompatible" => :kINCOMPATIBLE, @@ -1265,9 +1278,10 @@ "=" => :kEQ, "?" => :kQUESTION, "!" => :kEXCLAMATION, "**" => :kSTAR2, "*" => :kSTAR, + "..." => :kDOT3, "." => :kDOT, "<" => :kLT, "-@" => :tOPERATOR, "-" => :tOPERATOR, "/" => :tOPERATOR,