Class: YARD::Tags::TypesExplainer::Parser Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::YARD::CodeObjects
|
|
Inherits: | Object |
Defined in: | lib/yard/tags/types_explainer.rb |
Constant Summary
-
TOKENS =
# File 'lib/yard/tags/types_explainer.rb', line 99{ :collection_start => /</, :collection_end => />/, :fixed_collection_start => /\(/, :fixed_collection_end => /\)/, :type_name => /#{ISEP}#{METHODNAMEMATCH}|#{NAMESPACEMATCH}|\w+/, :type_next => /[,;]/, :whitespace => /\s+/, :hash_collection_start => /\{/, :hash_collection_next => /=>/, :hash_collection_end => /\}/, :parse_end => nil }
::YARD::CodeObjects
- Included
BUILTIN_ALL, BUILTIN_CLASSES, BUILTIN_EXCEPTIONS, BUILTIN_EXCEPTIONS_HASH, BUILTIN_MODULES, CONSTANTMATCH, CONSTANTSTART, CSEP, CSEPQ, ISEP, ISEPQ, METHODMATCH, METHODNAMEMATCH, NAMESPACEMATCH, NSEP, NSEPQ, PROXY_MATCH
Class Method Summary
- .new(string) ⇒ Parser constructor Internal use only
- .parse(string) Internal use only
Instance Method Summary
- #parse Internal use only
Class Method Details
.parse(string)
[ GitHub ]# File 'lib/yard/tags/types_explainer.rb', line 113
def self.parse(string) new(string).parse end
Instance Method Details
#parse
[ GitHub ]# File 'lib/yard/tags/types_explainer.rb', line 121
def parse types = [] type = nil name = nil loop do found = false TOKENS.each do |token_type, match| # TODO: cleanup this code. # rubocop:disable Lint/AssignmentInCondition next unless (match.nil? && @scanner.eos?) || (match && token = @scanner.scan(match)) found = true case token_type when :type_name raise SyntaxError, "expecting END, got name '#{token}'" if name name = token when :type_next raise SyntaxError, "expecting name, got '#{token}' at #{@scanner.pos}" if name.nil? type = Type.new(name) unless type types << type type = nil name = nil when :fixed_collection_start, :collection_start name ||= "Array" klass = token_type == :collection_start ? CollectionType : FixedCollectionType type = klass.new(name, parse) when :hash_collection_start name ||= "Hash" type = HashCollectionType.new(name, parse, parse) when :hash_collection_next, :hash_collection_end, :fixed_collection_end, :collection_end, :parse_end raise SyntaxError, "expecting name, got '#{token}'" if name.nil? type = Type.new(name) unless type types << type return types end end raise SyntaxError, "invalid character at #{@scanner.peek(1)}" unless found end end