github.com/blend/go-sdk@v1.20220411.3/selector/runes.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package selector 9 10 import "unicode" 11 12 func isWhitespace(ch rune) bool { 13 return unicode.IsSpace(ch) 14 } 15 16 func isNameSymbol(ch rune) bool { 17 switch ch { 18 case Dot, Dash, Underscore: 19 return true 20 } 21 return false 22 } 23 24 func isOperatorSymbol(ch rune) bool { 25 return ch == Bang || ch == Equal 26 } 27 28 func isSymbol(ch rune) bool { 29 return (int(ch) >= int(Bang) && int(ch) <= int(ForwardSlash)) || 30 (int(ch) >= int(Colon) && int(ch) <= int(At)) || 31 (int(ch) >= int(OpenBracket) && int(ch) <= int(BackTick)) || 32 (int(ch) >= int(OpenCurly) && int(ch) <= int(Tilde)) 33 } 34 35 func isAlpha(ch rune) bool { 36 return !isWhitespace(ch) && !unicode.IsControl(ch) && !isSymbol(ch) 37 } 38 39 func isDNSAlpha(ch rune) bool { 40 if unicode.IsDigit(ch) { 41 return true 42 } 43 if unicode.IsLetter(ch) { 44 return unicode.IsLower(ch) 45 } 46 return false 47 }