Class: YARD::Parser::RBS::RbsParser
- Defined in:
- lib/yard/parser/rbs/rbs_parser.rb
Overview
Parses RBS (Ruby type signature) files and produces a list of Statement objects for post-processing by handlers.
RBS is Ruby's official type signature format (introduced in Ruby 3.0). This parser handles: class/module/interface declarations, method signatures, attribute accessors, mixins, and constants.
No external gem dependencies are used; the parser is hand-written.
Constant Summary collapse
- MODIFIER =
Optional visibility modifier before a member, e.g.
private def. /(?:(?:public|private|protected)\s+)?/
Instance Method Summary collapse
-
#enumerator ⇒ Array<Statement>
Top-level statements for the post-processor.
-
#initialize(source, filename) ⇒ RbsParser
constructor
A new instance of RbsParser.
-
#parse ⇒ RbsParser
Parses the source and returns self.
-
#tokenize ⇒ Object
Tokenization is not implemented for RBS.
Constructor Details
#initialize(source, filename) ⇒ RbsParser
Returns a new instance of RbsParser.
19 20 21 22 23 |
# File 'lib/yard/parser/rbs/rbs_parser.rb', line 19 def initialize(source, filename) @source = source @filename = filename @statements = nil end |
Instance Method Details
#enumerator ⇒ Array<Statement>
Returns top-level statements for the post-processor.
39 40 41 |
# File 'lib/yard/parser/rbs/rbs_parser.rb', line 39 def enumerator @statements end |
#parse ⇒ RbsParser
Parses the source and returns self.
27 28 29 30 31 |
# File 'lib/yard/parser/rbs/rbs_parser.rb', line 27 def parse lines = @source.lines.map { |l| l.chomp } @statements, = parse_body(lines, 0, false) self end |
#tokenize ⇒ Object
Tokenization is not implemented for RBS.
34 35 36 |
# File 'lib/yard/parser/rbs/rbs_parser.rb', line 34 def tokenize raise NotImplementedError, "RBS parser does not support tokenization" end |