package lexer import "github.com/mmakaay/toml/parser" // Item types that are emitted by this parser. const ( ItemComment parser.ItemType = iota // An error occurred 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 escapeChars string = `btnfr"\` shortUtf8Escape string = "u" longUtf8Escape string = "U" ) var ( doubleQuote3 = []string{doubleQuote, doubleQuote, doubleQuote} shortUtf8Match = []string{backslash, "u", hex, hex, hex, hex} longUtf8Match = []string{backslash, "U", hex, hex, hex, hex, hex, hex, hex, hex} ) // NewParser creates a new parser, using the provided input string // as the data to parse. func NewParser(input string) *parser.Parser { return parser.New(input, stateKeyValuePair) }