package parser import "github.com/mmakaay/toml/parsekit" // Item types that are produced by this parser. const ( ItemComment parsekit.ItemType = iota // Comment string ItemKey // Key of a key/value pair ItemKeyDot // Dot for a dotted key ItemAssignment // Value assignment coming up (=) ItemString // A value of type string ) const ( whitespace string = " \t" carriageReturn string = "\r" newline string = "\n" hash string = "#" equal string = "=" lower string = "abcdefghijklmnopqrstuvwxyz" upper string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" digits string = "0123456789" hex string = digits + "abcdefABCDEF" dot string = "." underscore string = "_" dash string = "-" singleQuote string = "'" doubleQuote string = "\"" backslash string = "\\" quoteChars string = singleQuote + doubleQuote bareKeyChars string = lower + upper + digits + underscore + dash startOfKey string = bareKeyChars + quoteChars validEscapeChars string = `btnfr"\` mustBeEscaped string = "" + "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + "\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F" + "\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + "\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + "\u007F" ) var ( keySeparatorDot = []interface{}{whitespace, dot, whitespace} doubleQuote3 = []interface{}{doubleQuote, doubleQuote, doubleQuote} hex4 = []interface{}{hex, hex, hex, hex} shortUtf8Match = []interface{}{backslash, 'u', hex4} longUtf8Match = []interface{}{backslash, 'U', hex4, hex4} ) // NewParser creates a new parser, using the provided input string // as the data to parse. func NewParser(input string) *parsekit.P { return parsekit.New(input, startKeyValuePair) }