Skip to content

Commit

Permalink
Merge pull request #1 from pelletier/master
Browse files Browse the repository at this point in the history
Pull commits from pelletier/go-toml
  • Loading branch information
goldspy98 authored Mar 31, 2017
2 parents 5d9715d + e32a2e0 commit b2635fe
Show file tree
Hide file tree
Showing 16 changed files with 1,672 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ before_install:
branches:
only: [master]
after_success:
- $HOME/gopath/bin/goveralls -service=travis-ci
- $HOME/gopath/bin/goveralls -service=travis-ci -coverprofile=coverage.out -repotoken $COVERALLS_TOKEN
8 changes: 4 additions & 4 deletions lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type tomlLexer struct {
// Basic read operations on input

func (l *tomlLexer) read() rune {
r, err := l.input.ReadRune()
r, _, err := l.input.ReadRune()
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func (l *tomlLexer) emit(t tokenType) {
}

func (l *tomlLexer) peek() rune {
r, err := l.input.ReadRune()
r, _, err := l.input.ReadRune()
if err != nil {
panic(err)
}
Expand All @@ -99,7 +99,7 @@ func (l *tomlLexer) peek() rune {

func (l *tomlLexer) follow(next string) bool {
for _, expectedRune := range next {
r, err := l.input.ReadRune()
r, _, err := l.input.ReadRune()
defer l.input.UnreadRune()
if err != nil {
panic(err)
Expand Down Expand Up @@ -219,7 +219,7 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
break
}

possibleDate := string(l.input.Peek(35))
possibleDate := string(l.input.PeekRunes(35))
dateMatch := dateRegexp.FindString(possibleDate)
if dateMatch != "" {
l.fastForward(len(dateMatch))
Expand Down
24 changes: 24 additions & 0 deletions lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,30 @@ func TestKeyEqualStringUnicodeEscape(t *testing.T) {
{Position{1, 8}, tokenString, "hello δ"},
{Position{1, 25}, tokenEOF, ""},
})
testFlow(t, `foo = "\uabcd"`, []token{
{Position{1, 1}, tokenKey, "foo"},
{Position{1, 5}, tokenEqual, "="},
{Position{1, 8}, tokenString, "\uabcd"},
{Position{1, 15}, tokenEOF, ""},
})
testFlow(t, `foo = "\uABCD"`, []token{
{Position{1, 1}, tokenKey, "foo"},
{Position{1, 5}, tokenEqual, "="},
{Position{1, 8}, tokenString, "\uABCD"},
{Position{1, 15}, tokenEOF, ""},
})
testFlow(t, `foo = "\U000bcdef"`, []token{
{Position{1, 1}, tokenKey, "foo"},
{Position{1, 5}, tokenEqual, "="},
{Position{1, 8}, tokenString, "\U000bcdef"},
{Position{1, 19}, tokenEOF, ""},
})
testFlow(t, `foo = "\U000BCDEF"`, []token{
{Position{1, 1}, tokenKey, "foo"},
{Position{1, 5}, tokenEqual, "="},
{Position{1, 8}, tokenString, "\U000BCDEF"},
{Position{1, 19}, tokenEOF, ""},
})
testFlow(t, `foo = "\u2"`, []token{
{Position{1, 1}, tokenKey, "foo"},
{Position{1, 5}, tokenEqual, "="},
Expand Down
Loading

0 comments on commit b2635fe

Please sign in to comment.