Increased test coverage, remove dead code

This commit is contained in:
Derek Collison
2015-01-10 18:32:30 -08:00
parent 42ea437f21
commit 99f1ea29bd
2 changed files with 49 additions and 51 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2013 Apcera Inc. All rights reserved.
// Copyright 2013-2015 Apcera Inc. All rights reserved.
// Customized heavily from
// https://github.com/BurntSushi/toml/blob/master/lex.go, which is based on
@@ -154,15 +154,6 @@ func (lx *lexer) backup() {
}
}
// accept consumes the next rune if it's equal to `valid`.
func (lx *lexer) accept(valid rune) bool {
if lx.next() == valid {
return true
}
lx.backup()
return false
}
// peek returns but does not consume the next rune in the input.
func (lx *lexer) peek() rune {
r := lx.next()
@@ -362,8 +353,8 @@ func lexValue(lx *lexer) stateFn {
case isNL(r):
return lx.errorf("Expected value but found new line")
}
lx.backup()
return lexString
//return lx.errorf("Expected value but found '%s' instead.", r)
}
// lexArrayValue consumes one value in an array. It assumes that '[' or ','
@@ -529,17 +520,6 @@ func lexMapValue(lx *lexer) stateFn {
switch {
case isWhitespace(r) || isNL(r):
return lexSkip(lx, lexMapValue)
case r == commentHashStart:
lx.push(lexMapValue)
return lexCommentStart
case r == commentSlashStart:
rn := lx.next()
if rn == commentSlashStart {
lx.push(lexMapValue)
return lexCommentStart
}
lx.backup()
fallthrough
case r == mapValTerm:
return lx.errorf("Unexpected map value terminator %q.", mapValTerm)
case r == mapEnd:
@@ -649,32 +629,6 @@ func lexString(lx *lexer) stateFn {
return lexString
}
// lexDubString consumes the inner contents of a string. It assumes that the
// beginning '"' has already been consumed and ignored.
func lexDubString(lx *lexer) stateFn {
r := lx.next()
switch {
case r == '\\':
return lexStringEscape
// Termination of non-quoted strings
case isNL(r) || r == eof || r == optValTerm || isWhitespace(r):
lx.backup()
if lx.isBool() {
lx.emit(itemBool)
} else {
lx.emit(itemString)
}
return lx.pop()
case r == dqStringEnd:
lx.backup()
lx.emit(itemString)
lx.next()
lx.ignore()
return lx.pop()
}
return lexDubString
}
// lexBlock consumes the inner contents as a string. It assumes that the
// beginning '(' has already been consumed and ignored. It will continue
// processing until it finds a ')' on a new line by itself.