|
|
@ -68,9 +68,14 @@ func (p *parser) parseValue() (interface{}, error) {
|
|
|
|
case t_string:
|
|
|
|
case t_string:
|
|
|
|
return t.s, nil
|
|
|
|
return t.s, nil
|
|
|
|
case t_list_start:
|
|
|
|
case t_list_start:
|
|
|
|
l := new(list)
|
|
|
|
return p.parseList(new(list))
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("parse error: unexpected %v token while looking for value", t.t)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SIN:
|
|
|
|
func (p *parser) parseList(l *list) (*list, error) {
|
|
|
|
if p.peek().t == t_list_end {
|
|
|
|
if p.peek().t == t_list_end {
|
|
|
|
p.next()
|
|
|
|
p.next()
|
|
|
|
return l, nil
|
|
|
|
return l, nil
|
|
|
@ -84,14 +89,10 @@ func (p *parser) parseValue() (interface{}, error) {
|
|
|
|
|
|
|
|
|
|
|
|
switch t := p.next(); t.t {
|
|
|
|
switch t := p.next(); t.t {
|
|
|
|
case t_list_separator:
|
|
|
|
case t_list_separator:
|
|
|
|
goto SIN
|
|
|
|
return p.parseList(l)
|
|
|
|
case t_list_end:
|
|
|
|
case t_list_end:
|
|
|
|
return l, nil
|
|
|
|
return l, nil
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("parse error: unexpected %v token while scanning for list", t.t)
|
|
|
|
return nil, fmt.Errorf("parse error: unexpected %v token while scanning for list", t.t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("parse error: unexpected %v token while looking for value", t.t)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|