Code cleanup.
This commit is contained in:
parent
5ccb16f38f
commit
68ab1293f2
|
@ -22,14 +22,14 @@ test-a:
|
|||
numactl --physcpubind=+1 bash -c "time ./A < testfile.toml"
|
||||
|
||||
profile-a:
|
||||
numactl --physcpubind=+1 bash -c "./A -p 100 < testfile.toml"
|
||||
numactl --physcpubind=+1 bash -c "./A -p 250 < testfile.toml"
|
||||
|
||||
|
||||
test-b:
|
||||
numactl --physcpubind=+2 bash -c "time ./B < testfile.toml"
|
||||
|
||||
profile-b:
|
||||
numactl --physcpubind=+2 bash -c "./B -p 100 < testfile.toml"
|
||||
numactl --physcpubind=+2 bash -c "./B -p 250 < testfile.toml"
|
||||
|
||||
test-sushi:
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ var (
|
|||
// Both [tables] and [[arrays of tables]] start with a square open bracket.
|
||||
detectTable = a.SquareOpen
|
||||
|
||||
whiteSpaceNewlinesAndComments = whitespaceInclNewlines.Or(comment)
|
||||
whitespaceNewlinesAndComments = whitespaceInclNewlines.Or(comment)
|
||||
)
|
||||
|
||||
func (t *parser) startDocument(p *parse.API) {
|
||||
for {
|
||||
switch {
|
||||
case p.Accept(whiteSpaceNewlinesAndComments):
|
||||
case p.Accept(whitespaceNewlinesAndComments):
|
||||
// NOOP
|
||||
case p.Peek(detectTable):
|
||||
p.Handle(t.startTable)
|
||||
|
|
|
@ -14,21 +14,21 @@ var (
|
|||
// Multi-line basic strings are surrounded by three quotation marks on each
|
||||
// side and allow newlines.
|
||||
|
||||
doubleQuote3 = a.Str(`"""`)
|
||||
openingMultiLineBasicString = doubleQuote3.Then(newline.Optional())
|
||||
closingMultiLineBasicString = m.Drop(doubleQuote3)
|
||||
multiLineBasicStringDelimiter = a.Str(`"""`)
|
||||
openingMultiLineBasicString = multiLineBasicStringDelimiter.Then(newline.Optional())
|
||||
closingMultiLineBasicString = m.Drop(multiLineBasicStringDelimiter)
|
||||
|
||||
// Multi-line literal strings are surrounded by three single quotes on each side and allow newlines.
|
||||
|
||||
singleQuote3 = a.Str(`'''`)
|
||||
openingMultiLineLiteralString = singleQuote3.Then(newline.Optional())
|
||||
closingMultiLineLiteralString = m.Drop(singleQuote3)
|
||||
multiLineLiteralStringDelimiter = a.Str(`'''`)
|
||||
openingMultiLineLiteralString = multiLineLiteralStringDelimiter.Then(newline.Optional())
|
||||
closingMultiLineLiteralString = m.Drop(multiLineLiteralStringDelimiter)
|
||||
|
||||
// Closing character for basic strings.
|
||||
closingDoubleQuote = m.Drop(a.DoubleQuote)
|
||||
// Opening and closing character for basic strings.
|
||||
basicStringDelimiter = m.Drop(a.DoubleQuote)
|
||||
|
||||
// Closing character for literal strings.
|
||||
closingSingleQuote = m.Drop(a.SingleQuote)
|
||||
// Opening and losing character for literal strings.
|
||||
literalStringDelimiter = m.Drop(a.SingleQuote)
|
||||
|
||||
// Control characters as defined by TOML (U+0000 to U+001F, U+007F)
|
||||
|
||||
|
@ -67,13 +67,13 @@ func (t *parser) parseString(p *parse.API) (*ast.Value, bool) {
|
|||
var value string
|
||||
var ok bool
|
||||
switch {
|
||||
case p.Peek(doubleQuote3):
|
||||
case p.Peek(openingMultiLineBasicString):
|
||||
value, ok = t.parseMultiLineBasicString(p)
|
||||
case p.Peek(a.DoubleQuote):
|
||||
case p.Peek(basicStringDelimiter):
|
||||
value, ok = t.parseBasicString("string value", p)
|
||||
case p.Peek(singleQuote3):
|
||||
case p.Peek(openingMultiLineLiteralString):
|
||||
value, ok = t.parseMultiLineLiteralString(p)
|
||||
case p.Peek(a.SingleQuote):
|
||||
case p.Peek(literalStringDelimiter):
|
||||
value, ok = t.parseLiteralString("string value", p)
|
||||
default:
|
||||
p.Expected("a string value")
|
||||
|
@ -113,7 +113,7 @@ func (t *parser) parseBasicString(name string, p *parse.API) (string, bool) {
|
|||
case p.Peek(a.Backslash):
|
||||
p.Error("invalid escape sequence")
|
||||
return sb.String(), false
|
||||
case p.Accept(closingDoubleQuote):
|
||||
case p.Accept(basicStringDelimiter):
|
||||
return sb.String(), true
|
||||
case p.Peek(a.InvalidRune):
|
||||
p.Error("invalid UTF8 rune")
|
||||
|
@ -142,7 +142,7 @@ func (t *parser) parseLiteralString(name string, p *parse.API) (string, bool) {
|
|||
sb := &strings.Builder{}
|
||||
for {
|
||||
switch {
|
||||
case p.Accept(closingSingleQuote):
|
||||
case p.Accept(literalStringDelimiter):
|
||||
return sb.String(), true
|
||||
case p.Accept(a.Tab):
|
||||
sb.WriteString("\t")
|
||||
|
|
Loading…
Reference in New Issue