MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / parseStringLiteral

Method parseStringLiteral

go/engine/expr/parser.go:311–341  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

309}
310
311func (p *parser) parseStringLiteral() (Value, error) {
312 p.pos++ // skip opening "
313 var b strings.Builder
314 for p.pos < len(p.input) {
315 ch := p.input[p.pos]
316 if ch == '"' {
317 p.pos++
318 return StringVal(b.String()), nil
319 }
320 if ch == '\\' && p.pos+1 < len(p.input) {
321 p.pos++
322 switch p.input[p.pos] {
323 case 'n':
324 b.WriteByte('\n')
325 case 't':
326 b.WriteByte('\t')
327 case '"':
328 b.WriteByte('"')
329 case '\\':
330 b.WriteByte('\\')
331 default:
332 b.WriteByte(p.input[p.pos])
333 }
334 p.pos++
335 continue
336 }
337 b.WriteByte(ch)
338 p.pos++
339 }
340 return StringVal(b.String()), nil
341}
342
343func (p *parser) parseNumber() (Value, error) {
344 start := p.pos

Callers 1

parseAtomMethod · 0.95

Calls 2

StringValFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected