42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/parser/edn-util.rb', line 42
def app_parser_level1_diagnostics(e, node)
outbytes = 0
if $options.level input = node.input
ol1pos = l1pos = node.interval.begin
while outbytes <= e.position
outbytes += 1
ol1pos = l1pos
c1 = input[l1pos]
if c1 == "\\" c2 = input[l1pos += 1]
if c2 == "u" c3 = input[l1pos += 1]
if c3 == "{"
l1pos = input.index("}", l1pos)
else
if (input[l1pos, 4].to_i(16) & 0xFC00) == 0xD800 l1pos += 6 end
l1pos += 3 end
end
end
l1pos += 1
end
intv = ol1pos...l1pos
else
intv = node.interval.end...(node.interval.end+1) node.elements.each_with_index do |el, i|
outbytes += el.ast.size
if outbytes > e.position
intv = el.interval
break
end
end
end
failure_index = intv.begin
failure_line = node.input.line_of(failure_index)
failure_column = node.input.column_of(failure_index)
reason = "** Line #{failure_line}, column #{failure_column}:\n"
if line = node.input.lines.to_a[failure_line - 1]
reason << line
reason << "\n#{'~' * (failure_column - 1)}#{'^' * intv.size}"
end
warn reason
end
|