class AdLint::Cpp::EscapeSequence
Public Class Methods
new(str)
click to toggle source
TODO: Remove duplication in cc1/util.rb and cpp/util.rb .
# File lib/adlint/cpp/util.rb, line 37 def initialize(str) @str = str end
Public Instance Methods
value()
click to toggle source
# File lib/adlint/cpp/util.rb, line 41 def value case @str when "\\'" then "'".ord when "\\\"" then "\"".ord when "\\?" then "?".ord when "\\\\" then "\\".ord when "\\a" then "\a".ord when "\\b" then "\b".ord when "\\f" then "\f".ord when "\\n" then "\n".ord when "\\r" then "\r".ord when "\\t" then "\t".ord when "\\v" then "\v".ord else case @str when /\A\\([0-9]{1,3})\z/ $1.to_i(8) when /\A\\x([0-9A-F]+)\z/i $1.to_i(16) when /\A\\u([0-9A-F]{4,8})\z/i $1.to_i(16) else 0 end end end