// Literal inserts a string literal into the ARN being constructed
969298
func (iamRes *IAMResourceBuilder) Literal(arnPart string) *IAMResourceBuilder {
	iamRes.resourceParts = append(iamRes.resourceParts,
		gocf.String(arnPart))
	return iamRes
}
328326
func lexLiteral(l *lexer) stateFn {
	l.next()
	for done := false; !done; {
		switch r := l.next(); r {
		case backSlash:
			if nr := l.peek(); nr == quote {
				l.next()
				continue
			}
		case quote:
			l.backup()
			if !l.consume(literalType) {
				l.emitError("literals require a type definintion; missing ^^type:")
				return nil
			}
			literalT := ""
			for {
				r := l.next()
				if !(unicode.IsLetter(r) || unicode.IsDigit(r)) || r == eof {
					break
				}
				literalT += string(r)
			}
			literalT = strings.ToLower(literalT)
			switch literalT {
			case literalBool, literalInt, literalFloat, literalText, literalBlob:
				l.backup()
				l.emit(ItemLiteral)
				done = true
			default:
				l.emitError("invalid literal type " + literalT)
				return nil
			}
		case eof:
			l.emitError("literals needs to be properly terminated; missing \" and type")
			return nil
		}
	}
	return lexSpace
}
1127500
func Literal(v interface{}) Expression {
	value, err := sqltypes.BuildValue(v)
	if err != nil {
		panic(errors.Wrap(err, "Invalid literal value"))
	}
	return &literalExpression{value: value}
}
403777
func (e *Entity) Literal(path ...string) (Literal, error) {
	var cur = e
	var ok bool
	var lit Literal
	for i, prop := range path {
		var val Object
		val, ok = cur.Objects[Property(prop)]
		if !ok {
			return nil, ErrPathNotFound
		}
		if i == len(path)-1 {
			lit, ok = val.(Literal)
			if !ok {
				return nil, errors.Wrapf(ErrNotALiteral, "%#v", cur)
			}
			return lit, nil
		}
		cur, ok = val.(*Entity)
		if !ok {
			return nil, ErrPathNotFound
		}
	}
	return nil, ErrEmptyPath
}
932572
func (l *Literal) Int64() (int64, error) {
	if l.t != Int64 {
		return 0, fmt.Errorf("literal.Int64: literal is of type %v; cannot be converted to a int64", l.t)
	}
	return l.v.(int64), nil
}
673344
func (a *ARN) String() string {
	return strings.Join(
		[]string{a.ARN, a.AWS, a.Service, a.Region, a.Account, a.Resource},
		delimiter,
	)
}
401089
func (l *Literal) String() string {
	return fmt.Sprintf("\"%v\"^^type:%v", l.Interface(), l.Type())
}
1236248
func (m LiteralMap) Convert() (map[string]*Value, error) {
	ret := make(map[string]*Value, len(m))
	for k, v := range m {
		v, err := NewValue(v)
		if err != nil {
			return nil, fmt.Errorf("key %q: %s", k, err)
		}
		ret[k] = v
	}
	return ret, nil
}
456809
func (me *DefaultAdapter) LiteralString(buf *SqlBuilder, s string) error {
	if buf.IsPrepared {
		return me.PlaceHolderSql(buf, s)
	}
	buf.WriteRune(me.StringQuote)
	for _, char := range s {
		if e, ok := me.EscapedRunes[char]; ok {
			buf.Write(e)
		} else {
			buf.WriteRune(char)
		}
	}

	buf.WriteRune(me.StringQuote)
	return nil
}
45255
func ToLiteral(ce ConsumedElement) (*literal.Literal, error) {
	if ce.IsSymbol() {
		return nil, fmt.Errorf("semantic.ToLiteral cannot convert symbol %v to a literal", ce)
	}
	tkn := ce.Token()
	if tkn.Type != lexer.ItemLiteral {
		return nil, fmt.Errorf("semantic.ToLiteral cannot convert token type %s to a literal", tkn.Type)
	}
	return literal.DefaultBuilder().Parse(tkn.Text)
}
468965
func (me *DefaultAdapter) LiteralInt(buf *SqlBuilder, i int64) error {
	if buf.IsPrepared {
		return me.PlaceHolderSql(buf, i)
	}
	buf.WriteString(strconv.FormatInt(i, 10))
	return nil
}
51448
func (b *unboundBuilder) Parse(s string) (*Literal, error) {
	raw := strings.TrimSpace(s)
	if len(raw) == 0 {
		return nil, fmt.Errorf("literal.Parse: cannot parse and empty string into a literal; provided string %q", s)
	}
	if raw[0] != '"' {
		return nil, fmt.Errorf("literal.Parse: text encoded literals must start with \", missing in %s", raw)
	}
	idx := strings.Index(raw, "\"^^type:")
	if idx < 0 {
		return nil, fmt.Errorf("literal.Parse: text encoded literals must have a type; missing in %s", raw)
	}
	v := raw[1:idx]
	t := raw[idx+len("\"^^type:"):]
	switch t {
	case "bool":
		pv, err := strconv.ParseBool(v)
		if err != nil {
			return nil, fmt.Errorf("literal.Parse: could not convert value %q to bool", v)
		}
		return b.Build(Bool, pv)
	case "int64":
		pv, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			return nil, fmt.Errorf("literal.Parse: could not convert value %q to int64", v)
		}
		return b.Build(Int64, int64(pv))
	case "float64":
		pv, err := strconv.ParseFloat(v, 64)
		if err != nil {
			return nil, fmt.Errorf("literal.Parse: could not convert value %q to float64", v)
		}
		return b.Build(Float64, float64(pv))
	case "text":
		return b.Build(Text, v)
	case "blob":
		values := v[1 : len(v)-1]
		if values == "" {
			return b.Build(Blob, []byte{})
		}
		bs := []byte{}
		for _, s := range strings.Split(values, " ") {
			b, err := strconv.ParseUint(s, 10, 8)
			if err != nil {
				return nil, fmt.Errorf("literal.Parse: failed to decode byte array on %q with error %v", s, err)
			}
			bs = append(bs, byte(b))
		}
		return b.Build(Blob, bs)
	default:
		return nil, nil
	}
}
1354053
func (c Context) Str(key, val string) Context {
	c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val)
	return c
}
759868
func (engine *Engine) Quote(value string) string {
	value = strings.TrimSpace(value)
	if len(value) == 0 {
		return value
	}

	if string(value[0]) == engine.dialect.QuoteStr() || value[0] == '`' {
		return value
	}

	value = strings.Replace(value, ".", engine.dialect.QuoteStr()+"."+engine.dialect.QuoteStr(), -1)

	return engine.dialect.QuoteStr() + value + engine.dialect.QuoteStr()
}
363405
func (t Term) Insert(arg interface{}, optArgs ...InsertOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}
	return constructMethodTerm(t, "Insert", p.Term_INSERT, []interface{}{Expr(arg)}, opts)
}
386137
func (env *CustomEnv) Const(ident string) reflect.Value {
	if v := env.Env.Const(ident); v.IsValid() && v.Type().Kind() == reflect.String {
		s := v.String()
		return(reflect.ValueOf(strings.ToLower(s)))
	} else {
		return v
	}
}
522342
func (me *DefaultAdapter) LiteralExpressionSql(buf *SqlBuilder, literal LiteralExpression) error {
	lit := literal.Literal()
	args := literal.Args()
	argsLen := len(args)
	if argsLen > 0 {
		currIndex := 0
		for _, char := range lit {
			if char == replacement_rune && currIndex < argsLen {
				if err := me.Literal(buf, args[currIndex]); err != nil {
					return err
				}
				currIndex++
			} else {
				buf.WriteRune(char)
			}
		}
	} else {
		buf.WriteString(lit)
	}
	return nil
}