func nextJSCtx(s []byte, preceding jsCtx) jsCtx {
	s = bytes.TrimRight(s, "\t\n\f\r \u2028\u2029")
	if len(s) == 0 {
		return preceding
	}
	switch c, n := s[len(s)-1], len(s); c {
	case '+', '-':
		start := n - 1
		for start > 0 && s[start-1] == c {
			start--
		}
		if (n-start)&1 == 1 {
			return jsCtxRegexp
		}
		return jsCtxDivOp
	case '.':
		if n != 1 && '0' <= s[n-2] && s[n-2] <= '9' {
			return jsCtxDivOp
		}
		return jsCtxRegexp
	case ',', '<', '>', '=', '*', '%', '&', '|', '^', '?':
		return jsCtxRegexp
	case '!', '~':
		return jsCtxRegexp
	case '(', '[':
		return jsCtxRegexp
	case ':', ';', '{':
		return jsCtxRegexp
	case '}':
		return jsCtxRegexp
	default:
		j := n
		for j > 0 && isJSIdentPart(rune(s[j-1])) {
			j--
		}
		if regexpPrecederKeywords[string(s[j:])] {
			return jsCtxRegexp
		}
	}
	return jsCtxDivOp
}
nextJSCtx returns the context that determines whether a slash after the
given run of tokens starts a regular expression instead of a division
operator: / or /=.

This assumes that the token run does not include any string tokens, comment
tokens, regular expression literal tokens, or division operators.

This fails on some valid but nonsensical JavaScript programs like
"x = ++/foo/i" which is quite different than "x++/foo/i", but is not known to
fail on any known useful programs. It is based on the draft
JavaScript 2.0 lexical grammar and requires one token of lookbehind:
http://www.mozilla.org/js/language/js20-2000-07/rationale/syntax.html
package template
import (
	"bytes"
	"encoding/json"
	"fmt"
	"reflect"
	"strings"
	"unicode/utf8"
)