data

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2021 Lee Boynton

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ArgumentErrorKey = Intern("argument-error:")
View Source
var ErrorKey = Intern("error:")

ErrorKey - used for generic errors. By convention, error data (which is a vector of values), should have a keyword as the first element, and then a message as the second, and then optional other data after that.

View Source
var IOErrorKey = Intern("io-error:")
View Source
var KeywordType = primitiveType("<keyword>")
View Source
var NullType = primitiveType("<null>")
View Source
var SymbolType = primitiveType("<symbol>")
View Source
var SyntaxErrorKey = Intern("syntax-error:")

Functions

func EncodeString

func EncodeString(s string) string

EncodeString - return the encoded form of a string value

func Equal

func Equal(o1 Value, o2 Value) bool

func IsDelimiter

func IsDelimiter(b byte) bool

func IsPrimitiveType

func IsPrimitiveType(tag Value) bool

func IsType

func IsType(o Value) bool

func IsValidKeywordName

func IsValidKeywordName(s string) bool

func IsValidStructKey

func IsValidStructKey(d Value) bool

func IsValidSymbolName

func IsValidSymbolName(name string) bool

func IsValidTypeName

func IsValidTypeName(s string) bool

func IsWhitespace

func IsWhitespace(b byte) bool

func NumberEqual

func NumberEqual(f1 float64, f2 float64) bool

func TypeNameOf

func TypeNameOf(val Value) string

Types

type Boolean

type Boolean struct {
	Value bool
}
var False *Boolean = &Boolean{Value: false}
var True *Boolean = &Boolean{Value: true}

func (*Boolean) Equals

func (b1 *Boolean) Equals(another Value) bool

func (*Boolean) String

func (data *Boolean) String() string

func (*Boolean) Type

func (data *Boolean) Type() Value

type Character

type Character struct {
	Value rune
}

func NewCharacter

func NewCharacter(c rune) *Character

func (*Character) Equals

func (c *Character) Equals(another Value) bool

func (*Character) String

func (c *Character) String() string

func (*Character) Type

func (c *Character) Type() Value

type Error

type Error struct {
	Data Value
}

func MakeError

func MakeError(elements ...Value) *Error

func NewError

func NewError(errkey Value, args ...interface{}) *Error

func (*Error) Equals

func (err1 *Error) Equals(another Value) bool

func (*Error) Error

func (err *Error) Error() string

for golang error

func (*Error) String

func (err *Error) String() string

func (*Error) Type

func (err *Error) Type() Value

type Instance

type Instance struct {
	TypeTag Value
	Value   Value
}

Instance - a type/data value pair, i.e. `#<point>{x: 23 y: 57}` which is a struct tagged with the <point> type The 'type' of an instance is determined by a tag, i.e. it is not a primitive type

func (*Instance) Equals

func (i1 *Instance) Equals(another Value) bool

func (*Instance) String

func (data *Instance) String() string

func (*Instance) Type

func (data *Instance) Type() Value

this is not a primitive type, it is determined by the tag.

type Keyword

type Keyword struct {
	Text string //the textual representation of the Keyword
}

Keywords are symbolic identifiers with a trailing ':', i.e. `foo:`

func (*Keyword) Equals

func (kw *Keyword) Equals(another Value) bool

func (*Keyword) Name

func (kw *Keyword) Name() string

func (*Keyword) String

func (kw *Keyword) String() string

func (*Keyword) Type

func (kw *Keyword) Type() Value

type List

type List struct {
	Car Value
	Cdr *List
}
var EmptyList *List = &List{}

func Cons

func Cons(car Value, cdr *List) *List

Cons - create a new list consisting of the first object and the rest of the list

func ListFromValues

func ListFromValues(values []Value) *List

func NewList

func NewList(values ...Value) *List

func (*List) Equals

func (lst1 *List) Equals(another Value) bool

func (*List) Length

func (lst *List) Length() int

func (*List) String

func (lst *List) String() string

func (*List) Type

func (lst *List) Type() Value

type NullValue

type NullValue struct {
}

func (*NullValue) Equals

func (v *NullValue) Equals(another Value) bool

func (*NullValue) String

func (v *NullValue) String() string

func (*NullValue) Type

func (v *NullValue) Type() Value

type Number

type Number struct {
	Value float64
}

func Float

func Float(f float64) *Number

func Integer

func Integer(i int) *Number

func (*Number) Equals

func (n *Number) Equals(another Value) bool

func (*Number) Float64Value

func (n *Number) Float64Value() float64

func (*Number) IntValue

func (n *Number) IntValue() int

func (*Number) RuneValue

func (n *Number) RuneValue() rune

func (*Number) String

func (n *Number) String() string

func (*Number) Type

func (n *Number) Type() Value

type Reader

type Reader struct {
	Input     *bufio.Reader
	Position  int
	Extension ReaderExtension
}

func (*Reader) DecodeAtom

func (dr *Reader) DecodeAtom(firstChar byte) (Value, error)

func (*Reader) DecodeAtomString

func (dr *Reader) DecodeAtomString(firstChar byte) (string, error)

func (*Reader) DecodeComment

func (dr *Reader) DecodeComment() error

func (*Reader) DecodeList

func (dr *Reader) DecodeList() (Value, error)

func (*Reader) DecodeReaderMacro

func (dr *Reader) DecodeReaderMacro() (Value, error)

func (*Reader) DecodeSequence

func (dr *Reader) DecodeSequence(endChar byte) ([]Value, error)

func (*Reader) DecodeString

func (dr *Reader) DecodeString() (Value, error)

func (*Reader) DecodeStruct

func (dr *Reader) DecodeStruct() (Value, error)

func (*Reader) DecodeType

func (dr *Reader) DecodeType(firstChar byte) (string, error)

func (*Reader) DecodeVector

func (dr *Reader) DecodeVector() (Value, error)

func (*Reader) GetChar

func (dr *Reader) GetChar() (byte, error)

func (*Reader) Read

func (reader *Reader) Read() (Value, error)

func (*Reader) ReadAll

func (reader *Reader) ReadAll() (*List, error)

ReadAll - read all items in the input, returning a list of them.

func (*Reader) ReadValue

func (dr *Reader) ReadValue() (Value, error)

func (*Reader) SkipToData

func (dr *Reader) SkipToData(skipColon bool) (byte, error)

func (*Reader) UngetChar

func (dr *Reader) UngetChar() error

type ReaderExtension

type ReaderExtension interface {
	HandleChar(c byte) (Value, error, bool)
	HandleReaderMacro(c byte) (Value, error, bool)
}

type String

type String struct {
	Value string
}

func NewString

func NewString(s string) *String

func (*String) Equals

func (s *String) Equals(another Value) bool

func (*String) String

func (s *String) String() string

func (*String) Type

func (s *String) Type() Value

type Struct

type Struct struct {
	Bindings map[StructKey]Value
	Error    error
}
var EmptyStruct *Struct = NewStruct()

func MakeStruct

func MakeStruct(fieldvals []Value) (*Struct, error)

MakeStruct - create a new <struct> object from the arguments, which can be other structs, or key/value pairs

func NewStruct

func NewStruct() *Struct

func (*Struct) Equals

func (s1 *Struct) Equals(another Value) bool

Equal returns true if the object is equal to the argument

func (*Struct) Get

func (strct *Struct) Get(key Value) Value

func (*Struct) Has

func (strct *Struct) Has(key Value) bool

func (*Struct) Length

func (data *Struct) Length() int

func (*Struct) Put

func (strct *Struct) Put(key Value, val Value) *Struct

func (*Struct) String

func (d *Struct) String() string

func (*Struct) Type

func (d *Struct) Type() Value

func (*Struct) Unput

func (strct *Struct) Unput(key Value) *Struct

func (*Struct) Value

func (d *Struct) Value() Value

type StructKey

type StructKey struct {
	Value string
	Type  string
}

func (StructKey) ToValue

func (k StructKey) ToValue() Value

type Symbol

type Symbol struct {
	Text  string //the textual representation of the Symbol
	Value Value  //A hook for a value to bound to the symbol. Used by Ell, not actually part of EllDn Spec.
}

Symbols are symbolic identifiers, i.e. Intern("foo") == Intern("foo"), the same objects.

func (*Symbol) Equals

func (s1 *Symbol) Equals(another Value) bool

func (*Symbol) Name

func (data *Symbol) Name() string

func (*Symbol) String

func (data *Symbol) String() string

func (*Symbol) Type

func (data *Symbol) Type() Value

type Type

type Type struct {
	Text string //only the Name is needed for builtin types

}

Type is a type tag, of the form <foo> for type Foo. Types are part of the data notation.

func (*Type) Equals

func (t1 *Type) Equals(another Value) bool

func (*Type) Name

func (data *Type) Name() string

func (*Type) String

func (data *Type) String() string

func (*Type) Type

func (data *Type) Type() Value

type Value

type Value interface {
	Type() Value
	String() string
	Equals(another Value) bool
}
var AnyType Value = Intern("<any>")

not a concrete type, used as a type assertion that any type is ok. Note that the Read function lets the caller choose whether or not the keys should be coerced to a specific type (<keyword>, <symbol>, <string>) or not <any>

var BooleanType Value = primitiveType("<boolean>")
var CharacterType Value = Intern("<character>")
var EmptyString Value = NewString("")
var ErrorType Value = primitiveType("<error>")

Q: do I really need this? It is not part of EllDN. It has Instance syntax anyway. So...like UUID/Timestamp, right?

var ListType Value = MakeType("<list>")
var Null Value = &NullValue{}
var NumberType Value = primitiveType("<number>")
var StringType Value = primitiveType("<string>")
var StructType Value = primitiveType("<struct>")
var TypeType Value = primitiveType("<type>")
var VectorType Value = MakeType("<vector>")

func Intern

func Intern(name string) Value

func MakeType

func MakeType(name string) Value

func NewInstance

func NewInstance(tag Value, value Value) (Value, error)

func Symbols

func Symbols() []Value

func ToKeyword

func ToKeyword(o Value) (Value, error)

func ToSymbol

func ToSymbol(obj Value) (Value, error)

type Vector

type Vector struct {
	Elements []Value
}
var EmptyVector *Vector = VectorFromElementsNoCopy(nil) //NewVector()

func ListToVector

func ListToVector(lst *List) *Vector

func MakeVector

func MakeVector(size int, init Value) *Vector

func NewVector

func NewVector(elements ...Value) *Vector

func VectorFromElements

func VectorFromElements(elements []Value, count int) *Vector

VectorFromElements - return a new <vector> object from the given slice of elements. The slice is copied.

func VectorFromElementsNoCopy

func VectorFromElementsNoCopy(elements []Value) *Vector

func (*Vector) Equals

func (v1 *Vector) Equals(another Value) bool

func (*Vector) String

func (v *Vector) String() string

func (*Vector) Type

func (v *Vector) Type() Value

type Writer

type Writer struct {
	Json      bool
	Indent    string
	Extension WriterExtension
}

func (*Writer) Write

func (writer *Writer) Write(val Value) (string, error)

func (*Writer) WriteAll

func (writer *Writer) WriteAll(lst *List) (string, error)

func (*Writer) WriteData

func (writer *Writer) WriteData(o Value, json bool, indent string, indentSize string) (string, error)

func (*Writer) WriteList

func (writer *Writer) WriteList(lst *List, indent string, indentSize string) string

func (*Writer) WriteStruct

func (writer *Writer) WriteStruct(strct *Struct, json bool, indent string, indentSize string) (string, error)

func (*Writer) WriteVector

func (writer *Writer) WriteVector(vec *Vector, json bool, indent string, indentSize string) (string, error)

type WriterExtension

type WriterExtension interface {
	HandleValue(v Value) (string, error, bool)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL