aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/pelletier/go-toml/keysparsing.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2019-07-07 21:33:44 +0100
committerNiall Sheridan <nsheridan@gmail.com>2019-07-07 21:33:44 +0100
commit8c12c6939aab9106db14ec2d11d983bc5b29fb2c (patch)
treef9dc8a7d167c6355e47a65c52d4eb7b9ea03e6c8 /vendor/github.com/pelletier/go-toml/keysparsing.go
parent0bd454cc448b812da6c693b451d86ff4cadbb6b2 (diff)
Switch to modules
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/keysparsing.go')
-rw-r--r--vendor/github.com/pelletier/go-toml/keysparsing.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go
deleted file mode 100644
index 284db64..0000000
--- a/vendor/github.com/pelletier/go-toml/keysparsing.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// Parsing keys handling both bare and quoted keys.
-
-package toml
-
-import (
- "bytes"
- "errors"
- "fmt"
- "unicode"
-)
-
-// Convert the bare key group string to an array.
-// The input supports double quotation to allow "." inside the key name,
-// but escape sequences are not supported. Lexers must unescape them beforehand.
-func parseKey(key string) ([]string, error) {
- groups := []string{}
- var buffer bytes.Buffer
- inQuotes := false
- wasInQuotes := false
- ignoreSpace := true
- expectDot := false
-
- for _, char := range key {
- if ignoreSpace {
- if char == ' ' {
- continue
- }
- ignoreSpace = false
- }
- switch char {
- case '"':
- if inQuotes {
- groups = append(groups, buffer.String())
- buffer.Reset()
- wasInQuotes = true
- }
- inQuotes = !inQuotes
- expectDot = false
- case '.':
- if inQuotes {
- buffer.WriteRune(char)
- } else {
- if !wasInQuotes {
- if buffer.Len() == 0 {
- return nil, errors.New("empty table key")
- }
- groups = append(groups, buffer.String())
- buffer.Reset()
- }
- ignoreSpace = true
- expectDot = false
- wasInQuotes = false
- }
- case ' ':
- if inQuotes {
- buffer.WriteRune(char)
- } else {
- expectDot = true
- }
- default:
- if !inQuotes && !isValidBareChar(char) {
- return nil, fmt.Errorf("invalid bare character: %c", char)
- }
- if !inQuotes && expectDot {
- return nil, errors.New("what?")
- }
- buffer.WriteRune(char)
- expectDot = false
- }
- }
- if inQuotes {
- return nil, errors.New("mismatched quotes")
- }
- if buffer.Len() > 0 {
- groups = append(groups, buffer.String())
- }
- if len(groups) == 0 {
- return nil, errors.New("empty key")
- }
- return groups, nil
-}
-
-func isValidBareChar(r rune) bool {
- return isAlphanumeric(r) || r == '-' || unicode.IsNumber(r)
-}