// GraphQL charset: [_A-Za-z][_0-9A-Za-z]*
// (https://facebook.github.io/graphql/#sec-Names)
// IRI charset: [^#x00-#x20<>"{}|^`\]
// (https://www.w3.org/TR/turtle/#grammar-production-IRIREF)
545254
func allowedNameRune(r rune) bool {
	// will include <> in the IRI value
	return r > 0x20 && !strings.ContainsRune("\"{}()|^`", r) && !unicode.IsSpace(r)
}
218281
func ci(s string) bson.RegEx {
	return bson.RegEx{Pattern: fmt.Sprintf("^%s$", regexp.QuoteMeta(s)), Options: "i"}
}
361896
func NormaliseCharset(characterSet string) string {
	characterSet = strings.ToUpper(characterSet)
	switch characterSet {
	case "UTF8", "UT-8", "UTR-8", "UFT-8", "UTF8-WITHOUT-BOM", "UTF8_GENERAL_CI":
		return "UTF-8"
	// override Japanese
	// CP943: IBM OS/2 Japanese, superset of Cp932 and Shift-JIS
	case "CP943", "CP943C", "SIFT_JIS", "SHIFT-JIS":
		return "SHIFT_JIS"
	// override Korean
	case "EUC-KR", "MS949", "KSC5601", "WINDOWS-949", "KS_C_5601-1987", "KSC_5601":
		return "UHC"
	// override Thai
	//case "TIS-620", "WINDOWS-874":
	//	return "ISO-8859-11"
	// override latin-2
	case "LATIN2_HUNGARIAN_CI", "LATIN2":
		return "LATIN-2"
	// override cyrillic
	case "WIN1251", "WIN-1251", "WINDOWS-1251":
		return "CP1251"
	// override Hebrew
	case "WINDOWS-1255":
		return "ISO-8859-8"
	// override Turkish
	//case "WINDOWS-1254":
	//	return "ISO-8859-9"
	// override the parsing of ISO-8859-1 to behave as Windows-1252 (CP1252):
	// in ISO-8859-1, everything from 128-255 in the ASCII table are ctrl characters,
	// whilst in CP1252 they're symbols
	// override Baltic
	case "WINDOWS-1257":
		return "ISO-8859-13"
	case "ANSI", "LATIN-1", "ISO", "RFC", "MACINTOSH", "8859-1", "8859-15", "ISO8859-1", "ISO8859-15", "ISO-8559-1", "ISO-8859-1", "ISO-8859-15":
		return "CP1252"
	}
	return characterSet
}
1190002
func BQL() *Grammar {
	return &Grammar{
		"START": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemQuery),
					NewSymbol("VARS"),
					NewTokenType(lexer.ItemFrom),
					NewSymbol("INPUT_GRAPHS"),
					NewSymbol("WHERE"),
					NewSymbol("GROUP_BY"),
					NewSymbol("ORDER_BY"),
					NewSymbol("HAVING"),
					NewSymbol("GLOBAL_TIME_BOUND"),
					NewSymbol("LIMIT"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemInsert),
					NewTokenType(lexer.ItemData),
					NewTokenType(lexer.ItemInto),
					NewSymbol("OUTPUT_GRAPHS"),
					NewTokenType(lexer.ItemLBracket),
					NewTokenType(lexer.ItemNode),
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("INSERT_OBJECT"),
					NewSymbol("INSERT_DATA"),
					NewTokenType(lexer.ItemRBracket),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDelete),
					NewTokenType(lexer.ItemData),
					NewTokenType(lexer.ItemFrom),
					NewSymbol("INPUT_GRAPHS"),
					NewTokenType(lexer.ItemLBracket),
					NewTokenType(lexer.ItemNode),
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("DELETE_OBJECT"),
					NewSymbol("DELETE_DATA"),
					NewTokenType(lexer.ItemRBracket),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemCreate),
					NewSymbol("CREATE_GRAPHS"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDrop),
					NewSymbol("DROP_GRAPHS"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemConstruct),
					NewSymbol("CONSTRUCT_FACTS"),
					NewTokenType(lexer.ItemInto),
					NewSymbol("OUTPUT_GRAPHS"),
					NewTokenType(lexer.ItemFrom),
					NewSymbol("INPUT_GRAPHS"),
					NewSymbol("WHERE"),
					NewSymbol("HAVING"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDeconstruct),
					NewSymbol("DECONSTRUCT_FACTS"),
					NewTokenType(lexer.ItemIn),
					NewSymbol("OUTPUT_GRAPHS"),
					NewTokenType(lexer.ItemFrom),
					NewSymbol("INPUT_GRAPHS"),
					NewSymbol("WHERE"),
					NewSymbol("HAVING"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemShow),
					NewSymbol("GRAPH_SHOW"),
					NewTokenType(lexer.ItemSemicolon),
				},
			},
		},
		"CREATE_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemGraph),
					NewSymbol("GRAPHS"),
				},
			},
		},
		"DROP_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemGraph),
					NewSymbol("GRAPHS"),
				},
			},
		},
		"VARS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("VARS_AS"),
					NewSymbol("MORE_VARS"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemCount),
					NewTokenType(lexer.ItemLPar),
					NewSymbol("COUNT_DISTINCT"),
					NewTokenType(lexer.ItemBinding),
					NewTokenType(lexer.ItemRPar),
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_VARS"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemSum),
					NewTokenType(lexer.ItemLPar),
					NewTokenType(lexer.ItemBinding),
					NewTokenType(lexer.ItemRPar),
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_VARS"),
				},
			},
		},
		"COUNT_DISTINCT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDistinct),
				},
			},
			{},
		},
		"VARS_AS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"MORE_VARS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewSymbol("VARS"),
				},
			},
			{},
		},
		"GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_GRAPHS"),
				},
			},
		},
		"MORE_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_GRAPHS"),
				},
			},
			{},
		},
		"INPUT_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_INPUT_GRAPHS"),
				},
			},
		},
		"MORE_INPUT_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_INPUT_GRAPHS"),
				},
			},
			{},
		},
		"OUTPUT_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_OUTPUT_GRAPHS"),
				},
			},
		},
		"MORE_OUTPUT_GRAPHS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("MORE_OUTPUT_GRAPHS"),
				},
			},
			{},
		},
		"WHERE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemWhere),
					NewTokenType(lexer.ItemLBracket),
					NewSymbol("CLAUSES"),
					NewTokenType(lexer.ItemRBracket),
				},
			},
		},
		"CLAUSES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
					NewSymbol("SUBJECT_EXTRACT"),
					NewSymbol("PREDICATE"),
					NewSymbol("OBJECT"),
					NewSymbol("MORE_CLAUSES"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("SUBJECT_EXTRACT"),
					NewSymbol("PREDICATE"),
					NewSymbol("OBJECT"),
					NewSymbol("MORE_CLAUSES"),
				},
			},
		},
		"SUBJECT_EXTRACT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("SUBJECT_TYPE"),
					NewSymbol("SUBJECT_ID"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemType),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("SUBJECT_ID"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"SUBJECT_TYPE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemType),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"SUBJECT_ID": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"PREDICATE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("PREDICATE_AS"),
					NewSymbol("PREDICATE_ID"),
					NewSymbol("PREDICATE_AT"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicateBound),
					NewSymbol("PREDICATE_AS"),
					NewSymbol("PREDICATE_ID"),
					NewSymbol("PREDICATE_BOUND_AT"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("PREDICATE_AS"),
					NewSymbol("PREDICATE_ID"),
					NewSymbol("PREDICATE_AT"),
				},
			},
		},
		"PREDICATE_AS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"PREDICATE_ID": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"PREDICATE_AT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAt),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"PREDICATE_BOUND_AT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAt),
					NewSymbol("PREDICATE_BOUND_AT_BINDINGS"),
				},
			},
			{},
		},
		"PREDICATE_BOUND_AT_BINDINGS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("PREDICATE_BOUND_AT_BINDINGS_END"),
				},
			},
			{},
		},
		"PREDICATE_BOUND_AT_BINDINGS_END": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLiteral),
					NewSymbol("OBJECT_LITERAL_AS"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
					NewSymbol("OBJECT_SUBJECT_EXTRACT"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("OBJECT_PREDICATE_AS"),
					NewSymbol("OBJECT_PREDICATE_ID"),
					NewSymbol("OBJECT_PREDICATE_AT"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicateBound),
					NewSymbol("OBJECT_PREDICATE_AS"),
					NewSymbol("OBJECT_PREDICATE_ID"),
					NewSymbol("OBJECT_PREDICATE_BOUND_AT"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("OBJECT_LITERAL_BINDING_AS"),
					NewSymbol("OBJECT_LITERAL_BINDING_TYPE"),
					NewSymbol("OBJECT_LITERAL_BINDING_ID"),
					NewSymbol("OBJECT_LITERAL_BINDING_AT"),
				},
			},
		},
		"OBJECT_SUBJECT_EXTRACT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("OBJECT_SUBJECT_TYPE"),
					NewSymbol("OBJECT_SUBJECT_ID"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemType),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("OBJECT_SUBJECT_ID"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_SUBJECT_TYPE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemType),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_SUBJECT_ID": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_AS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_ID": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_AT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAt),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_BOUND_AT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAt),
					NewSymbol("OBJECT_PREDICATE_BOUND_AT_BINDINGS"),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_BOUND_AT_BINDINGS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("OBJECT_PREDICATE_BOUND_AT_BINDINGS_END"),
				},
			},
			{},
		},
		"OBJECT_PREDICATE_BOUND_AT_BINDINGS_END": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_LITERAL_AS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_LITERAL_BINDING_AS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAs),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_LITERAL_BINDING_TYPE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemType),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_LITERAL_BINDING_ID": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemID),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"OBJECT_LITERAL_BINDING_AT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAt),
					NewTokenType(lexer.ItemBinding),
				},
			},
			{},
		},
		"MORE_CLAUSES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDot),
					NewSymbol("CLAUSES"),
				},
			},
			{},
		},
		"GROUP_BY": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemGroup),
					NewTokenType(lexer.ItemBy),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("GROUP_BY_BINDINGS"),
				},
			},
			{},
		},
		"GROUP_BY_BINDINGS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("GROUP_BY_BINDINGS"),
				},
			},
			{},
		},
		"ORDER_BY": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemOrder),
					NewTokenType(lexer.ItemBy),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("ORDER_BY_DIRECTION"),
					NewSymbol("ORDER_BY_BINDINGS"),
				},
			},
			{},
		},
		"ORDER_BY_DIRECTION": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAsc),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDesc),
				},
			},
			{},
		},
		"ORDER_BY_BINDINGS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemBinding),
					NewSymbol("ORDER_BY_DIRECTION"),
					NewSymbol("ORDER_BY_BINDINGS"),
				},
			},
			{},
		},
		"HAVING": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemHaving),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{},
		},
		"HAVING_CLAUSE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("HAVING_CLAUSE_BINARY_COMPOSITE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNot),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLPar),
					NewSymbol("HAVING_CLAUSE"),
					NewTokenType(lexer.ItemRPar),
					NewSymbol("HAVING_CLAUSE_BINARY_COMPOSITE"),
				},
			},
		},
		"HAVING_CLAUSE_BINARY_COMPOSITE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAnd),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemOr),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemEQ),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLT),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemGT),
					NewSymbol("HAVING_CLAUSE"),
				},
			},
			{},
		},
		"GLOBAL_TIME_BOUND": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBefore),
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemAfter),
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBetween),
					NewTokenType(lexer.ItemPredicate),
					NewTokenType(lexer.ItemComma),
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{},
		},
		"LIMIT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLimit),
					NewTokenType(lexer.ItemLiteral),
				},
			},
			{},
		},
		"INSERT_OBJECT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLiteral),
				},
			},
		},
		"INSERT_DATA": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDot),
					NewTokenType(lexer.ItemNode),
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("INSERT_OBJECT"),
					NewSymbol("INSERT_DATA"),
				},
			},
			{},
		},
		"DELETE_OBJECT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLiteral),
				},
			},
		},
		"DELETE_DATA": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDot),
					NewTokenType(lexer.ItemNode),
					NewTokenType(lexer.ItemPredicate),
					NewSymbol("DELETE_OBJECT"),
					NewSymbol("DELETE_DATA"),
				},
			},
			{},
		},
		"CONSTRUCT_FACTS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLBracket),
					NewSymbol("CONSTRUCT_TRIPLES"),
					NewTokenType(lexer.ItemRBracket),
				},
			},
		},
		"CONSTRUCT_TRIPLES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_CONSTRUCT_PREDICATE_OBJECT_PAIRS"),
					NewSymbol("MORE_CONSTRUCT_TRIPLES"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBlankNode),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_CONSTRUCT_PREDICATE_OBJECT_PAIRS"),
					NewSymbol("MORE_CONSTRUCT_TRIPLES"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_CONSTRUCT_PREDICATE_OBJECT_PAIRS"),
					NewSymbol("MORE_CONSTRUCT_TRIPLES"),
				},
			},
		},
		"CONSTRUCT_PREDICATE": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
				},
			},
		},
		"CONSTRUCT_OBJECT": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBlankNode),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemPredicate),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLiteral),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
				},
			},
		},
		"MORE_CONSTRUCT_PREDICATE_OBJECT_PAIRS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemSemicolon),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_CONSTRUCT_PREDICATE_OBJECT_PAIRS"),
				},
			},
			{},
		},
		"MORE_CONSTRUCT_TRIPLES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDot),
					NewSymbol("CONSTRUCT_TRIPLES"),
				},
			},
			{},
		},
		"DECONSTRUCT_FACTS": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemLBracket),
					NewSymbol("DECONSTRUCT_TRIPLES"),
					NewTokenType(lexer.ItemRBracket),
				},
			},
		},
		"DECONSTRUCT_TRIPLES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemNode),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_DECONSTRUCT_TRIPLES"),
				},
			},
			{
				Elements: []Element{
					NewTokenType(lexer.ItemBinding),
					NewSymbol("CONSTRUCT_PREDICATE"),
					NewSymbol("CONSTRUCT_OBJECT"),
					NewSymbol("MORE_DECONSTRUCT_TRIPLES"),
				},
			},
		},
		"MORE_DECONSTRUCT_TRIPLES": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemDot),
					NewSymbol("DECONSTRUCT_TRIPLES"),
				},
			},
			{},
		},
		"GRAPH_SHOW": []*Clause{
			{
				Elements: []Element{
					NewTokenType(lexer.ItemGraphs),
				},
			},
		},
	}
}
1215304
func (c *Captcha) genRandChars() string {
	return string(com.RandomCreateBytes(c.ChallengeNums, defaultChars...))
}
644216
func CharacterHref(c rune) string {
	switch {
	case '1' <= c && c <= '9':
		return PaletteHref(3, int(c-'1'))
	case 'A' <= c && c <= 'Z':
		return PaletteHref(5, int((c-'A')%8+16*((31-c+'A')/8)))
	default:
		return ""
	}
}
863681
func (t TokenBuilder) GtOrEqNamed(names ...string) Cmp {
	return t.cmp(geq, names)
}
944983
func SetPreferredLanguage(s string) error {
	// "C" is commonly used to denote a neutral POSIX locale. See http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_02
	if s == "" || s == "C" {
		SetPreferredLanguageTag(defaultLanguage)
		return nil
	}
	// Handles "de_DE" or "de_DE.utf8"
	// We don't process encodings, since Rob Pike invented utf8 and we're mostly stuck with it.
	parts := strings.Split(s, ".")
	l, err := language.Parse(parts[0])
	if err != nil {
		return err
	}
	SetPreferredLanguageTag(l)
	return nil
}
1071383
func (a *ArgType) reniltype(typ string) string {
	if strings.Contains(typ, ".") {
		return typ
	}

	if strings.HasSuffix(typ, "{}") {
		if _, ok := a.KnownTypeMap[typ[:len(typ)-2]]; ok {
			return typ
		}

		pkg := a.CustomTypePackage
		if pkg != "" {
			pkg = pkg + "."
		}

		return pkg + typ
	}

	return typ
}
856609
func argWidth(arg string) int {
	// Strip zero-width characters.
	replacer := strings.NewReplacer(
		"\n", "",
		"\t", "",
		"\r", "",
		"\f", "",
		"\v", "",
		string(bold), "",
		string(yellow), "",
		string(cyan), "",
		string(endColor), "",
	)
	s := replacer.Replace(arg)
	return utf8.RuneCountInString(s)
}
295854
func (t *Trie) convert(origin string) (result string) {
	root := t
	originRune := []rune(origin)
	result = ""

	for l := 0; l < len(originRune); l++ {
		t = root
		foundVal := ""
		depth := 0
		for i := 0; i+l < len(originRune); i++ {
			letter := string(originRune[l+i])
			if t.children[letter] == nil {
				// not found
				break
			}
			if len(t.children[letter].values) > 0 {
				foundVal = t.children[letter].values[0]
				depth = i
			}
			t = t.children[letter]
		}
		if foundVal != "" {
			result += foundVal
			l += depth
		} else {
			result += string(originRune[l : l+1])
		}
	}
	return result
}
1127964
func CharDescription(ch rune) string {
	/*if ch == '\\' {
		return "\\\\"
	}

	if ch > ' ' && ch <= '~' {
		return string(ch)
	} else if ch == '\n' {
		return "\\n"
	} else if ch == ' ' {
		return "\\ "
	}*/

	b := &bytes.Buffer{}
	escape(b, ch, false) //fmt.Sprintf("%U", ch)
	return b.String()
}
1034532
func (t *translator) C(key interface{}, num float64, digits uint64, param string) (string, error) {

	tarr, ok := t.cardinalTanslations[key]
	if !ok {
		return unknownTranslation, ErrUnknowTranslation
	}

	rule := t.CardinalPluralRule(num, digits)

	trans := tarr[rule]

	b := make([]byte, 0, 64)
	b = append(b, trans.text[:trans.indexes[0]]...)
	b = append(b, param...)
	b = append(b, trans.text[trans.indexes[1]:]...)

	return string(b), nil
}
488292
func (engine *Engine) Charset(charset string) *Session {
	session := engine.NewSession()
	session.IsAutoClose = true
	return session.Charset(charset)
}
1239036
func CharsetReader(charset string, input io.Reader) (io.Reader, error) {
	switch mapping[strings.ToLower(charset)] {
	case "utf-8":
		return input, nil
	case "iso-8859-1":
		return newISO88591CharsetReader(input), nil
	}
	return nil, fmt.Errorf("charset %q is not supported", charset)
}
22923
func (c *GraphClause) String() string {
	b := bytes.NewBufferString("{ ")

	// Subject section.
	if c.S != nil {
		b.WriteString(c.S.String())
	} else {
		b.WriteString(c.SBinding)
	}
	if c.SAlias != "" {
		b.WriteString(" AS ")
		b.WriteString(c.SAlias)
	}
	if c.STypeAlias != "" {
		b.WriteString(" TYPE ")
		b.WriteString(c.STypeAlias)
	}
	if c.SIDAlias != "" {
		b.WriteString(" ID ")
		b.WriteString(c.SIDAlias)
	}

	// Predicate section.
	predicate := false
	if c.P != nil {
		b.WriteString(" ")
		b.WriteString(c.P.String())
		predicate = true
	}
	if c.PBinding != "" {
		b.WriteString(" ")
		b.WriteString(c.PBinding)
	}
	if c.PID != "" {
		b.WriteString(" \"")
		b.WriteString(c.PID)
		b.WriteString("\"")
	}
	if !predicate {
		if !c.PTemporal {
			b.WriteString("@[]")
		} else {
			b.WriteString("@[")
			if c.PAnchorBinding != "" {
				b.WriteString(c.PAnchorBinding)
				if c.PAnchorAlias != "" {
					b.WriteString(" at ")
					b.WriteString(c.PAnchorAlias)
				}
			} else {
				if c.PLowerBound != nil {
					b.WriteString(c.PLowerBound.Format(time.RFC3339Nano))
				} else {
					if c.PLowerBoundAlias != "" {
						b.WriteString(c.PLowerBoundAlias)
					}
				}
				b.WriteString(",")
				if c.PUpperBound != nil {
					b.WriteString(c.PUpperBound.Format(time.RFC3339Nano))
				} else {
					if c.PUpperBoundAlias != "" {
						b.WriteString(c.PUpperBoundAlias)
					}
				}
			}
			b.WriteString("]")
		}
	}

	if c.PAlias != "" {
		b.WriteString(" AS ")
		b.WriteString(c.PAlias)
	}
	if c.PIDAlias != "" {
		b.WriteString(" ID ")
		b.WriteString(c.PIDAlias)
	}
	if c.PAnchorAlias != "" {
		b.WriteString(" AT ")
		b.WriteString(c.PAnchorAlias)
	}

	// Object section.
	// Node portion.
	object := false
	if c.O != nil {
		b.WriteString(" ")
		b.WriteString(c.O.String())
		object = true
	}
	// Predicate portion.
	if !object {
		if c.OBinding != "" {
			b.WriteString(" ")
			b.WriteString(c.OBinding)
		}
		if c.OID != "" {
			b.WriteString(" \"")
			b.WriteString(c.OID)
			b.WriteString("\"")
		}
		if !c.OTemporal {
			b.WriteString("[]")
		} else {
			b.WriteString("[")
			if c.OAnchorBinding != "" {
				b.WriteString(c.OAnchorBinding)
				if c.OAnchorAlias != "" {
					b.WriteString(" at ")
					b.WriteString(c.OAnchorAlias)
				}
			} else {
				if c.OLowerBound != nil {
					b.WriteString(c.OLowerBound.Format(time.RFC3339Nano))
				} else {
					if c.OLowerBoundAlias != "" {
						b.WriteString(c.OLowerBoundAlias)
					}
				}
				b.WriteString(",")
				if c.OUpperBound != nil {
					b.WriteString(c.OUpperBound.Format(time.RFC3339Nano))
				} else {
					if c.OUpperBoundAlias != "" {
						b.WriteString(c.OUpperBoundAlias)
					}
				}
			}
			b.WriteString("]")
		}
	}
	if c.OAlias != "" {
		b.WriteString(" AS ")
		b.WriteString(c.OAlias)
	}
	if c.OTypeAlias != "" {
		b.WriteString(" TYPE ")
		b.WriteString(c.OTypeAlias)
	}
	if c.OIDAlias != "" {
		b.WriteString(" ID ")
		b.WriteString(c.OIDAlias)
	}
	if c.OAnchorAlias != "" {
		b.WriteString(" AT ")
		b.WriteString(c.OAnchorAlias)
	}

	if c.OAlias != "" {
		b.WriteString(" AS ")
		b.WriteString(c.OAlias)
	}
	if c.OIDAlias != "" {
		b.WriteString(" ID ")
		b.WriteString(c.OIDAlias)
	}

	b.WriteString(" }")
	return b.String()
}
369443
func (b *BatchBuilder) ToCql() (stmt string, names []string) {
	cql := bytes.Buffer{}

	cql.WriteString("BEGIN ")
	if b.unlogged {
		cql.WriteString("UNLOGGED ")
	}
	if b.counter {
		cql.WriteString("COUNTER ")
	}
	cql.WriteString("BATCH ")

	names = append(names, b.using.writeCql(&cql)...)

	for _, stmt := range b.stmts {
		cql.WriteString(stmt)
		cql.WriteByte(';')
		cql.WriteByte(' ')
	}
	names = append(names, b.names...)

	cql.WriteString("APPLY BATCH ")

	stmt = cql.String()
	return
}