File: symbol.go

package info (click to toggle)
golang-github-twstrike-otr3 0.0~git20161015.0.744856d-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,080 kB
  • sloc: ansic: 127; makefile: 76
file content (33 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (3)
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)
}