lib/rbs/parser_aux.rb in rbs-3.5.0.pre.2 vs lib/rbs/parser_aux.rb in rbs-3.5.0

- old
+ new

@@ -1,7 +1,10 @@ # frozen_string_literal: true +require_relative "parser/lex_result" +require_relative "parser/token" + module RBS class Parser def self.parse_type(source, range: 0..., variables: [], require_eof: false) buf = buffer(source) _parse_type(buf, range.begin || 0, range.end || buf.last_position, variables, require_eof) @@ -15,9 +18,18 @@ def self.parse_signature(source) buf = buffer(source) dirs, decls = _parse_signature(buf, buf.last_position) [buf, dirs, decls] + end + + def self.lex(source) + buf = buffer(source) + list = _lex(buf, buf.last_position) + value = list.map do |type, location| + Token.new(type: type, location: location) + end + LexResult.new(buffer: buf, value: value) end def self.buffer(source) case source when String