-
Notifications
You must be signed in to change notification settings - Fork 0
/
tellRunes.go
39 lines (35 loc) · 1.13 KB
/
tellRunes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package runes
const (
ArrayClose = ']'
ArrayOpen = '['
ArraySeparator = ','
Colon = ':' // keywords in a signature are separated by a colon
Dash = '-' // values in a sequence are prefixed by a dash ( and whitespace )
Eof = -1
Escape = '\\'
Hash = '#' // comment marker
HTab = '\t' // invalid outside of strings or comments.
InterpretQuote = '"' // interpreted strings are bookended with double quotes
KeyValue = '\r' // in comment blocks, replaces both the key and the value.
Newline = '\n'
NextTerm = '\f' // form feed is used to separate comment entries
RawQuote = '`'
Redirect = '<' // for closing tags
Space = ' '
Underscore = '_' // valid in words between colons
)
// https://golang.org/ref/spec#decimal_digit
func IsNumber(r rune) bool {
return r >= '0' && r <= '9'
}
// https://golang.org/ref/spec#hex_digit
func IsHex(r rune) bool {
return (r >= 'a' && r <= 'f') || (r >= 'A' && r <= 'F') || IsNumber(r)
}
func IsWhitespace(q rune) (ret bool) {
switch q {
case Space, Newline, Eof:
ret = true
}
return
}