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.

45 lines
1.2 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 allows to work with symbolic expressions, s-expressions.
package sxpf
import (
// Value is a generic value, the set of all possible values of a s-expression.
type Value interface {
IsNil() bool // Compare to any nil value
Equal(Value) bool // Compare to any value
Print(io.Writer) error // Print representation to Writer
// IsNil returns true, if the value is an empty value.
func IsNil(val Value) bool {
return val == nil || val.IsNil()
// Repr returns the string representation of the given val.
func Repr(val Value) (string, error) {
var buf bytes.Buffer
if err := val.Print(&buf); err != nil {
return "", err
return buf.String(), nil
// Atom is a Value that cannot be further decomposed.
type Atom interface {
Value() string