lib/rbs/parser.y in rbs-1.0.0 vs lib/rbs/parser.y in rbs-1.0.1

- old
+ new

@@ -609,11 +609,11 @@ comment: leading_comment(val[0].first&.location || location) ) } type_decl: - annotations kTYPE qualified_name kEQ type { + annotations kTYPE type_alias_name kEQ type { location = val[1].location + val[4].location result = Declarations::Alias.new(name: val[2].value, type: val[4], annotations: val[0], location: location, @@ -1035,10 +1035,20 @@ type_name = TypeName.new(namespace: namespace, name: name) location = (loc0 = val[0]&.location) ? loc0 + val[1].location : val[1].location result = LocatedValue.new(value: type_name, location: location) } + type_alias_name: + namespace tLIDENT { + namespace = val[0]&.value || Namespace.empty + name = val[1].value.to_sym + type_name = TypeName.new(namespace: namespace, name: name) + location = (loc0 = val[0]&.location) ? loc0 + val[1].location : val[1].location + result = LocatedValue.new(value: type_name, location: location) + } + + namespace: { result = nil } | kCOLON2 { @@ -1359,10 +1369,10 @@ new_token(:kSELFQ, "self?") when input.scan(/(([a-zA-Z]\w*)|(_\w+))=/) new_token(:tWRITE_ATTR) when input.scan(KEYWORDS_RE) new_token(KEYWORDS[input.matched], input.matched.to_sym) - when input.scan(/:((@{,2}|\$)?\w+(\?|\!)?|\+|\-)\b?/) + when input.scan(/:((@{,2}|\$)?\w+(\?|\!)?|[|&\/%~`^]|<=>|={2,3}|=~|[<>]{2}|[<>]=?|[-+]@?|\*{1,2}|\[\]=?|![=~]?)\b?/) s = input.matched.yield_self {|s| s[1, s.length] }.to_sym new_token(:tSYMBOL, s) when input.scan(/[+-]?\d[\d_]*/) new_token(:tINTEGER, input.matched.to_i) when input.scan(PUNCTS_RE)