1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package sexp
import "bufio"
// Symbol represents an S-Expression symbol.
type Symbol string
// First will fail if called on a symbol
func (s Symbol) First() Value {
panic("not valid to call First on a Symbol")
}
// Second will fail if called on a symbol
func (s Symbol) Second() Value {
panic("not valid to call Second on a Symbol")
}
// String returns the symbol as a string
func (s Symbol) String() string {
return string(s)
}
// Value returns the symbol as a string
func (s Symbol) Value() interface{} {
return string(s)
}
// ReadSymbol will read a symbol from the reader
func ReadSymbol(r *bufio.Reader) Value {
ReadWhitespace(r)
result := ReadDataUntil(r, isNotSymbolCharacter)
return Symbol(result)
}
|