sexpr

package module
v0.0.0-...-e5cb6a0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 2 Imported by: 5

README

sexpr

No, it's not about Public Relations for a popular activity.

It's a bluntly stolen package - originally found in "github.com/awalterschulze/gominikanren".

Package sexpr implements symbolic expressions

API

type V = *ast.Variable
type X = *ast.SExpr

func Parse(s string) (X, error)

Note: Expression constructors such as

func NewSymbol(s string) X
func NewVariable(s string) X
func NewList(ss ...X) X

are provided as a convenience for test implementations only.


bnf

SExpr           : Atom
                | Pair
                ;

Pair            : "(" ")"                           
                | "(" SExpr ")"                     
                | "(" SExpr space ContinueList ")"  
                | "(" SExpr space "." space SExpr ")"  
                ;

ContinueList    : SExpr
                | SExpr space ContinueList
                ;

Atom            : symbol
                | int_lit
                | float_lit
                | string_lit
                | variable
                ;

go

type SExpr struct {
	*Pair
	*Atom
}

type Pair struct {
	Car, Cdr *SExpr
}

type Atom struct {
	Str    *string
	Symbol *string
	Float  *float64
	Int    *int64
	Var    *Variable
}

Documentation

Overview

Package sexpr implements symbolic expressions

Index

Constants

This section is empty.

Variables

View Source
var (
	Parse = sexpr.Parse

	Cons = ast.Cons

	NewString   = ast.NewString
	NewSymbol   = ast.NewSymbol
	NewInt      = ast.NewInt
	NewFloat    = ast.NewFloat
	NewVariable = ast.NewVariable

	NewList = ast.NewList
)

Functions

This section is empty.

Types

type Atom

type Atom = ast.Atom

type Expression

type Expression = ast.SExpr

type Pair

type Pair = ast.Pair

type Variable

type Variable = ast.Variable

Directories

Path Synopsis
cmd
Package sexpr implements a parser of symbolic expressions.
Package sexpr implements a parser of symbolic expressions.
ast

Jump to

Keyboard shortcuts

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