Exception: Rbind::ClangParser::ClangParserError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/rbind/clang_parser.rb

Instance Method Summary collapse

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(message,cursor)
    @cursor = cursor
    super(message)
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_sObject



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