Class: ParsingParcels
Overview
This is a collection of parsing aids to be used in other modules
Instance Method Summary collapse
-
#code_lines(input) ⇒ Object
This parser accepts a collection of lines which it will sweep through and tidy, giving the purified lines to the block (one line at a time) for further analysis.
Instance Method Details
#code_lines(input) ⇒ Object
This parser accepts a collection of lines which it will sweep through and tidy, giving the purified lines to the block (one line at a time) for further analysis. It analyzes a single line at a time, which is far more memory efficient and faster for large files. However, this requires it to also handle backslash line continuations as a single line at this point.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ceedling/parsing_parcels.rb', line 17 def code_lines(input) comment_block = false full_line = '' input.each_line do |line| m = line.match /(.*)\\\s*$/ if (!m.nil?) full_line += m[1] elsif full_line.empty? _line, comment_block = clean_code_line( line, comment_block ) yield( _line ) else _line, comment_block = clean_code_line( full_line + line, comment_block ) yield( _line ) full_line = '' end end end |