Just a bit of code formatting.

This commit is contained in:
Maurice Makaay 2019-05-19 23:44:11 +00:00
parent e3e408dfdb
commit 84ae34fb5f
2 changed files with 21 additions and 20 deletions

View File

@ -11,26 +11,24 @@ var (
// broken over multiple lines). // broken over multiple lines).
keyAssignment = c.Sequence(optionalWhitespace, equal, optionalWhitespace) keyAssignment = c.Sequence(optionalWhitespace, equal, optionalWhitespace)
// A key may be either bare, quoted or dotted. // A key may be either bare, quoted or dotted. Bare keys may only
// Bare keys may only contain ASCII letters, ASCII digits, // contain ASCII letters, ASCII digits, underscores, and dashes
// underscores, and dashes (A-Za-z0-9_-). Note that bare // (A-Za-z0-9_-). Note that bare keys are allowed to be composed of only
// keys are allowed to be composed of only ASCII digits, // ASCII digits, e.g. 1234, but are always interpreted as strings.
// e.g. 1234, but are always interpreted as strings.
bareKeyRune = c.AnyOf(lower, upper, digit, underscore, dash) bareKeyRune = c.AnyOf(lower, upper, digit, underscore, dash)
bareKey = c.OneOrMore(bareKeyRune) bareKey = c.OneOrMore(bareKeyRune)
// Quoted keys follow the exact same rules as either basic // Quoted keys follow the exact same rules as either basic strings or
// strings or literal strings and allow you to use a much broader // literal strings and allow you to use a much broader set of key names.
// set of key names. Best practice is to use bare keys except // Best practice is to use bare keys except when absolutely necessary.
// when absolutely necessary. // A bare key must be non-empty, but an empty quoted key is allowed
// A bare key must be non-empty, but an empty quoted key is // (though discouraged).
// allowed (though discouraged).
startOfKey = c.AnyOf(bareKeyRune, anyQuote) startOfKey = c.AnyOf(bareKeyRune, anyQuote)
// Dotted keys are a sequence of bare or quoted keys joined with a dot. // Dotted keys are a sequence of bare or quoted keys joined with a dot.
// This allows for grouping similar properties together. // This allows for grouping similar properties together. Whitespace
// Whitespace around dot-separated parts is ignored, however, best // around dot-separated parts is ignored, however, best practice is to
// practice is to not use any extraneous whitespace. // not use any extraneous whitespace.
keySeparatordDot = c.Sequence(optionalWhitespace, dot, optionalWhitespace) keySeparatordDot = c.Sequence(optionalWhitespace, dot, optionalWhitespace)
) )

View File

@ -3,15 +3,18 @@ package parser
import "github.com/mmakaay/toml/parsekit" import "github.com/mmakaay/toml/parsekit"
var ( var (
// There are four ways to express strings: basic, multi-line basic, literal, // There are four ways to express strings: basic, multi-line basic,
// and multi-line literal. All strings must contain only valid UTF-8 characters. // literal, and multi-line literal. All strings must contain only valid
// * Multi-line basic strings are surrounded by three quotation marks on each side. // UTF-8 characters. * Multi-line basic strings are surrounded by three
// * Basic strings are surrounded by quotation marks. // quotation marks on each side. * Basic strings are surrounded by
// quotation marks.
doubleQuote3 = c.Repeat(3, doubleQuote) doubleQuote3 = c.Repeat(3, doubleQuote)
// Any Unicode character may be used except those that must be escaped: // Any Unicode character may be used except those that must be escaped:
// quotation mark, backslash, and the control characters (U+0000 to U+001F, U+007F). // quotation mark, backslash, and the control characters (U+0000 to
charThatMustBeEscaped = c.AnyOf(c.RuneRange('\u0000', '\u001F'), c.Rune('\u007F')) // U+001F, U+007F).
charThatMustBeEscaped = c.AnyOf(c.RuneRange('\u0000', '\u001F'),
c.Rune('\u007F'))
// For convenience, some popular characters have a compact escape sequence. // For convenience, some popular characters have a compact escape sequence.
// //