Simplify JSON expression parsing

This commit is contained in:
Tobie Morgan Hitchcock 2016-11-04 09:45:11 +00:00
parent 28c70a792a
commit 28d1806785

View file

@ -105,13 +105,11 @@ func (p *parser) parseDiff() (exp []Expr, err error) {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
val, err := p.declare(tok, lit) one.JSON, err = p.declare(tok, lit)
if err != nil { if err != nil {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
one.JSON = val
exp = append(exp, one) exp = append(exp, one)
return return
@ -127,13 +125,11 @@ func (p *parser) parseMerge() (exp []Expr, err error) {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
val, err := p.declare(tok, lit) one.JSON, err = p.declare(tok, lit)
if err != nil { if err != nil {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
one.JSON = val
exp = append(exp, one) exp = append(exp, one)
return return
@ -149,13 +145,11 @@ func (p *parser) parseContent() (exp []Expr, err error) {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
val, err := p.declare(tok, lit) one.JSON, err = p.declare(tok, lit)
if err != nil { if err != nil {
return nil, &ParseError{Found: lit, Expected: []string{"json"}} return nil, &ParseError{Found: lit, Expected: []string{"json"}}
} }
one.JSON = val
exp = append(exp, one) exp = append(exp, one)
return return