Class: Ast::Merge::Comment::QuotedHashLineParser
- Inherits:
-
Object
- Object
- Ast::Merge::Comment::QuotedHashLineParser
- Defined in:
- lib/ast/merge/comment/quoted_hash_line_parser.rb
Overview
Parses single source lines for hash-style comments while respecting
quoted regions. This is intended for ambiguous inline # syntaxes
where a simple regex becomes brittle.
Defined Under Namespace
Instance Method Summary collapse
-
#initialize ⇒ QuotedHashLineParser
constructor
A new instance of QuotedHashLineParser.
-
#parse(line) ⇒ Result?
Parse a line into a normalized comment result.
Constructor Details
#initialize ⇒ QuotedHashLineParser
Returns a new instance of QuotedHashLineParser.
54 55 56 |
# File 'lib/ast/merge/comment/quoted_hash_line_parser.rb', line 54 def initialize @grammar = Grammar.new end |
Instance Method Details
#parse(line) ⇒ Result?
Parse a line into a normalized comment result.
62 63 64 65 66 67 68 69 70 |
# File 'lib/ast/merge/comment/quoted_hash_line_parser.rb', line 62 def parse(line) source = line.to_s tree = @grammar.parse(source) full_line_result(tree[:full_line], source) || inline_result(tree[:inline], source) rescue Parslet::ParseFailed nil end |