Sha256: 9224a1258c99ab82f8860e083682e8d87afb8b2f8e432bc58c2ce2247a523201
Contents?: true
Size: 720 Bytes
Versions: 3
Compression:
Stored size: 720 Bytes
Contents
module PLang module Parser class Error def Error.syntax_error(line, src, i, msg) error = "#{line}:sintax error: #{msg}\n#{Error.show_error(src, i)}" raise error end private def Error.show_error(src, i) _src = src[0,i] src[i,src.length].each_byte do |c| break if c.chr == "\n" _src += c.chr end pos = _src.length - i __src = "" _src.reverse.each_byte do |c| break if c.chr == "\n" __src += c.chr end __src = __src.reverse __src += "\n" (__src.length - pos -1).times do __src += " " end __src += "^" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
p-lang-0.3.1 | lib/parser/error.rb |
p-lang-0.3.0 | lib/parser/error.rb |
p-lang-0.2.0 | lib/parser/error.rb |