class YARD::Parser::Base
@since 0.5.6
@see #enumerator
@see #tokenize
@see #parse
@abstract
To register a parser, see {SourceParser.register_parser_type}
== Registering a Custom Parser
{#enumerator}.
a specific way. A parser should implement {#parse}, {#tokenize} and
Represents the abstract base parser class that parses source code in
def self.parse(source, filename = nil)
def self.parse(source, filename = nil) new(source, filename).parse end
def enumerator
-
(nil)- if no post-processing should be done -
(Array)- a list of semantic tokens representing the source code
Other tags:
- Abstract: -
def enumerator nil end
def initialize(source, filename) # rubocop:disable Lint/UnusedMethodArgument
-
filename(String) -- the name of the file if from disk -
source(String) -- the source contents
def initialize(source, filename) # rubocop:disable Lint/UnusedMethodArgument raise NotImplementedError, "invalid parser implementation" end
def parse
-
(Base)- this method should return itself
Other tags:
- Abstract: -
def parse raise NotImplementedError, "#{self.class} must implement #parse" end
def tokenize
-
(Array)- a list/tree of lexical tokens
Other tags:
- Abstract: -
def tokenize raise NotImplementedError, "#{self.class} does not support tokenization" end