Help us shape the future of Go! Take the 2026 Go Developer Survey

sexp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2016 License: MIT Imports: 5 Imported by: 6

README

Go(lang) S-expression Parser

This is a fork of https://bitbucket.org/shanehanna/sexp, with improved error handling.

Description.

A Go S-expression parser.

go get github.com/abesto/sexp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(data interface{}, canonical bool) ([]byte, error)

func NewLexer

func NewLexer(input []byte) *lexer

Lex S-Expressions.

See http://people.csail.mit.edu/rivest/Sexp.txt

* Unlike the R.Rivest 1997 draft tokens will match any unicode letters. * Canonical S-Expressions may have spaces between atoms which isn't strictly correct.

func Unmarshal

func Unmarshal(data []byte) ([]interface{}, error)

Types

type Item

type Item struct {
	Type     ItemType
	Position int
	Value    []byte
}

func (Item) String

func (item Item) String() string

type ItemType

type ItemType int
const (
	ItemEOF ItemType = iota
	ItemError
	ItemBracketLeft  // (
	ItemBracketRight // )
	ItemToken        // abc        Token.
	ItemQuote        // "abc"      Quoted string. May also include length 3"abc"
	ItemVerbatim     // 3:abc      Length prefixed "verbatim" encoding.

)

type Sexp

type Sexp struct {
	// contains filtered or unexported fields
}

func New

func New(data ...interface{}) (*Sexp, error)

func Parse

func Parse(data []byte) (*Sexp, error)

func (*Sexp) Array

func (s *Sexp) Array() ([]interface{}, error)

func (*Sexp) At

func (s *Sexp) At(index int) *Sexp

func (*Sexp) Bytes

func (s *Sexp) Bytes() ([]byte, error)

func (*Sexp) Encode

func (s *Sexp) Encode(canonical bool) ([]byte, error)

func (*Sexp) Pop

func (s *Sexp) Pop() (*Sexp, error)

func (*Sexp) Push

func (s *Sexp) Push(data ...interface{}) error

Jump to

Keyboard shortcuts

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