func parse_list(l *lexer.Lexer) (VValue, bool) { token := l.Peek() switch token.Type { case ")": l.Next() return VNil, true case "EOF": return nil, false case ".": l.Next() return parse(l) } if car, ok := parse(l); ok { if cdr, ok := parse_list(l); ok { if _, ok := cdr.(*VPair); !ok { if l.Next().Type != ")" { panic("Can't have multiple cdr expressions") } } return &VPair{car, cdr}, true } } return nil, false }