Skip to content

Commit

Permalink
Fix unexpected token type in inline table (#334)
Browse files Browse the repository at this point in the history
Fixes #321
  • Loading branch information
AllenX2018 authored Mar 10, 2020
1 parent d2d17bc commit 3503483
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (l *tomlLexer) lexLeftCurlyBrace() tomlLexStateFn {
func (l *tomlLexer) lexRightCurlyBrace() tomlLexStateFn {
l.next()
l.emit(tokenRightCurlyBrace)
return l.lexVoid
return l.lexRvalue
}

func (l *tomlLexer) lexDate() tomlLexStateFn {
Expand Down
33 changes: 33 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,39 @@ func TestDoubleInlineGroup(t *testing.T) {
})
}

func TestNestedInlineGroup(t *testing.T) {
tree, err := Load("out = {block0 = {x = 99, y = 100}, block1 = {p = \"999\", q = \"1000\"}}")
assertTree(t, tree, err, map[string]interface{}{
"out": map[string]interface{}{
"block0": map[string]interface{}{
"x": int64(99),
"y": int64(100),
},
"block1": map[string]interface{}{
"p": "999",
"q": "1000",
},
},
})
}

func TestArrayInNestedInlineGroup(t *testing.T) {
tree, err := Load(`image = {name = "xxx", palette = {id = 100, colors = ["red", "blue", "green"]}}`)
assertTree(t, tree, err, map[string]interface{}{
"image": map[string]interface{}{
"name": "xxx",
"palette": map[string]interface{}{
"id": int64(100),
"colors": []string{
"red",
"blue",
"green",
},
},
},
})
}

func TestExampleInlineGroup(t *testing.T) {
tree, err := Load(`name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }`)
Expand Down

0 comments on commit 3503483

Please sign in to comment.