// LitRuneFunc renders a rune literal. LitRuneFunc generates the value to
// render by executing the provided function.
323891
func (s *Statement) LitRuneFunc(f func() rune) *Statement {
	t := token{
		typ:     literalRuneToken,
		content: f(),
	}
	*s = append(*s, t)
	return s
}
1148498
func RuneWidth(r rune) int {
	switch {
	case r == utf8.RuneError || r < '\x20':
		return 0

	case '\x20' <= r && r < '\u2000':
		return 1

	case '\u2000' <= r && r < '\uFF61':
		return 2

	case '\uFF61' <= r && r < '\uFFA0':
		return 1

	case '\uFFA0' <= r:
		return 2
	}

	return 0
}
510418
func BrightCyan(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.BrightCyan()
	}
	return value{value: arg, color: BrightFg | CyanFg}
}
553237
func (v *View) parseInput(ch rune) []cell {
	cells := []cell{}

	isEscape, err := v.ei.parseOne(ch)
	if err != nil {
		for _, r := range v.ei.runes() {
			c := cell{
				fgColor: v.FgColor,
				bgColor: v.BgColor,
				chr:     r,
			}
			cells = append(cells, c)
		}
		v.ei.reset()
	} else {
		if isEscape {
			return nil
		}
		c := cell{
			fgColor: v.ei.curFgColor,
			bgColor: v.ei.curBgColor,
			chr:     ch,
		}
		cells = append(cells, c)
	}

	return cells
}
302926
func NewTrimFuncProcessor(f func(r rune) bool) ProcessorFunc {
	return func(in string) (string, bool) {
		return strings.TrimFunc(in, f), true
	}
}
862710
func anyRune(s string) runeFn {
	return func(r rune) bool {
		return strings.IndexRune(s, r) > -1
	}
}
1275160
func builtinFunc(name string) func(js JSWriter, args []ast.Node) {
	var funcStart = "soy.$$" + name + "("
	return func(js JSWriter, args []ast.Node) {
		js.Write(funcStart)
		for i, arg := range args {
			if i != 0 {
				js.Write(",")
			}
			js.Write(arg)
		}
		js.Write(")")
	}
}
545254
func allowedNameRune(r rune) bool {
	// will include <> in the IRI value
	return r > 0x20 && !strings.ContainsRune("\"{}()|^`", r) && !unicode.IsSpace(r)
}
592617
func BrightRed(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.BrightRed()
	}
	return value{value: arg, color: BrightFg | RedFg}
}
1124576
func LtOrEqFunc(column string, fn *Func) Cmp {
	return Cmp{
		op:     leq,
		column: column,
		value:  fn,
	}
}
108703
func unicoded(in string) (out string) {
	for i, v := range in {
		if v == 0xFFFD {
			return in[:i]
		}
	}
	return in
}
969298
func (iamRes *IAMResourceBuilder) Literal(arnPart string) *IAMResourceBuilder {
	iamRes.resourceParts = append(iamRes.resourceParts,
		gocf.String(arnPart))
	return iamRes
}
290899
func LtLit(column, literal string) Cmp {
	return Cmp{
		op:     lt,
		column: column,
		value:  lit(literal),
	}
}
1229792
func (p *parser) parseFuncTypeOrLit() ast.Expr {
	if p.trace {
		defer un(trace(p, "FuncTypeOrLit"))
	}

	typ, scope := p.parseFuncType()
	if p.tok != token.LBRACE {
		// function type only
		return typ
	}

	p.exprLev++
	body := p.parseBody(scope)
	p.exprLev--

	return &ast.FuncLit{typ, body}
}
591313
func (s *Statement) LitByte(v byte) *Statement {
	t := token{
		typ:     literalByteToken,
		content: v,
	}
	*s = append(*s, t)
	return s
}
1294946
func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) {
	switch {
	case tr.quickDict != nil:
		if r <= unicode.MaxASCII {
			result = tr.quickDict.Dict[r]

			if result != 0 {
				translated = true

				if tr.mappedRune >= 0 {
					result = tr.mappedRune
				}

				break
			}
		}

		fallthrough

	case tr.runeMap != nil:
		var ok bool

		if result, ok = tr.runeMap[r]; ok {
			translated = true

			if tr.mappedRune >= 0 {
				result = tr.mappedRune
			}

			break
		}

		fallthrough

	default:
		var rrm *runeRangeMap
		ranges := tr.ranges

		for i := len(ranges) - 1; i >= 0; i-- {
			rrm = ranges[i]

			if rrm.FromLo <= r && r <= rrm.FromHi {
				translated = true

				if tr.mappedRune >= 0 {
					result = tr.mappedRune
					break
				}

				if rrm.ToLo < rrm.ToHi {
					result = rrm.ToLo + r - rrm.FromLo
				} else if rrm.ToLo > rrm.ToHi {
					// ToHi can be smaller than ToLo if range is from higher to lower.
					result = rrm.ToLo - r + rrm.FromLo
				} else {
					result = rrm.ToLo
				}

				break
			}
		}
	}

	if tr.reverted {
		if !translated {
			result = tr.mappedRune
		}

		translated = !translated
	}

	if !translated {
		result = r
	}

	return
}
479820
func (l *StringLexer) AcceptRunFunc(fn func(r rune) bool) bool {
	guard := Mark("AcceptRun")
	defer guard()
	return AcceptRunFunc(l, fn)
}