1
0
Fork 0
Little S-Expression Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sxpf/symbol.go

45 lines
1.1 KiB

//-----------------------------------------------------------------------------
// Copyright (c) 2022 Detlef Stern
//
// This file is part of sxpf.
//
// sxpf is licensed under the latest version of the EUPL // (European Union
// Public License). Please see file LICENSE.txt for your rights and obligations
// under this license.
//-----------------------------------------------------------------------------
package sxpf
import (
"io"
"strings"
)
// Symbol is a value that identifies something.
type Symbol struct {
val string
}
// GetValue returns the string value of the symbol.
func (sym *Symbol) GetValue() string { return sym.val }
func (sym *Symbol) IsNil() bool { return sym == nil }
// Equal retruns true if the other value is equal to this one.
func (sym *Symbol) Equal(other Value) bool {
if sym == nil || IsNil(other) {
return sym == other
}
if o, ok := other.(*Symbol); ok {
return strings.EqualFold(sym.val, o.val)
}
return false
}
func (sym *Symbol) Print(w io.Writer) error {
_, err := io.WriteString(w, sym.val)
return err
}
func (sym *Symbol) String() string { return sym.val }
func (sym *Symbol) Value() string { return sym.val }