Files
aego/script/lexer/chars.go
T

38 lines
697 B
Go

package lexer
func isLetter(c byte) bool {
return c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
}
func isDigit(c byte) bool {
return c >= '0' && c <= '9'
}
func isHex(c byte) bool {
return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')
}
func isIdentPart(c byte) bool {
return isLetter(c) || isDigit(c)
}
func isDigitOrUnderscore(c byte) bool {
return isDigit(c) || c == '_'
}
func isHexOrUnderscore(c byte) bool {
return isHex(c) || c == '_'
}
func hexVal(c byte) int {
switch {
case c >= '0' && c <= '9':
return int(c - '0')
case c >= 'a' && c <= 'f':
return int(c-'a') + 10
case c >= 'A' && c <= 'F':
return int(c-'A') + 10
}
return -1
}