Exception: Rbind::ClangParser::ClangParserError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Rbind::ClangParser::ClangParserError
- Defined in:
- lib/rbind/clang_parser.rb
Instance Method Summary collapse
- #context(before = 10) ⇒ Object
-
#initialize(message, cursor) ⇒ ClangParserError
constructor
A new instance of ClangParserError.
- #to_s ⇒ Object
Constructor Details
#initialize(message, cursor) ⇒ ClangParserError
Returns a new instance of ClangParserError.
10 11 12 13 |
# File 'lib/rbind/clang_parser.rb', line 10 def initialize(,cursor) @cursor = cursor super() end |
Instance Method Details
#context(before = 10) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rbind/clang_parser.rb', line 15 def context(before = 10) file,row,cloumn = @cursor.location f = File.open(file) lines = f.readlines[[0,row-before].max..row-1] f.close lines end |
#to_s ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rbind/clang_parser.rb', line 23 def to_s location = @cursor.location con = context row = location[1] - con.size con = con.map do |line| row += 1 "#{row}:\t> #{line}" end pos_width = @cursor.location_int-@cursor.extent[:begin_int_data] pos_start = [location[2]-pos_width,0].max con << " \t " + " "*pos_start + "."*pos_width "#{super}\n\n#{"#"*5}\nParsed File: #{location.join(":")}\n#{con.join()}\n#{"#"*5}\n\n" rescue => e pp e end |