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

View File

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