|
|
@ -106,8 +106,7 @@ func readValue(r io.Reader) (value, error) {
|
|
|
|
case start_string:
|
|
|
|
case start_string:
|
|
|
|
return StringVal(line), nil
|
|
|
|
return StringVal(line), nil
|
|
|
|
case start_error:
|
|
|
|
case start_error:
|
|
|
|
line = line[:len(line)-2]
|
|
|
|
return ErrorVal(line), nil
|
|
|
|
return Error(line[1:]), nil
|
|
|
|
|
|
|
|
case start_integer:
|
|
|
|
case start_integer:
|
|
|
|
line = line[:len(line)-2]
|
|
|
|
line = line[:len(line)-2]
|
|
|
|
return Integer(line[1:]), nil
|
|
|
|
return Integer(line[1:]), nil
|
|
|
@ -141,13 +140,23 @@ func String(s string) value {
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
type Error string
|
|
|
|
type ErrorVal []byte
|
|
|
|
|
|
|
|
|
|
|
|
func (e Error) Write(w io.Writer) (int, error) {
|
|
|
|
func (e ErrorVal) Write(w io.Writer) (int, error) {
|
|
|
|
w.Write([]byte{'-'})
|
|
|
|
// w.Write([]byte{'-'})
|
|
|
|
w.Write([]byte(e))
|
|
|
|
// w.Write([]byte(e))
|
|
|
|
w.Write([]byte{'\r', '\n'})
|
|
|
|
// w.Write([]byte{'\r', '\n'})
|
|
|
|
return 0, nil
|
|
|
|
// return 0, nil
|
|
|
|
|
|
|
|
return w.Write(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Error(s string) value {
|
|
|
|
|
|
|
|
b := make(ErrorVal, len(s)+3)
|
|
|
|
|
|
|
|
b[0] = '-'
|
|
|
|
|
|
|
|
copy(b[1:], []byte(s))
|
|
|
|
|
|
|
|
b[len(b)-2] = '\r'
|
|
|
|
|
|
|
|
b[len(b)-1] = '\n'
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|