MCPcopy
hub / github.com/BishopFox/jsluice / String

Method String

strings.go:27–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25)
26
27func (i item) String() string {
28 switch i.typ {
29 case itemString:
30 return i.val
31 case itemSingleEscape:
32 escapes := map[string]string{
33 "b": "\b",
34 "f": "\f",
35 "n": "\n",
36 "r": "\r",
37 "t": "\t",
38 "v": "\v",
39 }
40
41 if out, exists := escapes[i.val]; exists {
42 return out
43 }
44 return i.val
45 case itemHexEscape, itemUnicodeEscape, itemCodepointEscape:
46 num, err := strconv.ParseInt(i.val, 16, 0)
47 if err != nil {
48 return i.val
49 }
50 return string(rune(num))
51 case itemOctalEscape:
52 num, err := strconv.ParseInt(i.val, 8, 0)
53 if err != nil {
54 return i.val
55 }
56 return string(rune(num))
57 default:
58 return i.val
59 }
60}
61
62// a stringLexer maintains the state needed to lex a string
63type stringLexer struct {

Callers 3

getTreeFunction · 0.45
StringMethod · 0.45
DecodeStringFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected