package ast

import "shirakumo.org/markless/ast"

Conversion to a component-type agnostic AST format.

This is used for testing primarily. If you are looking for documentation on the actual AST representation of a document, please check shirakumo.org/markless/components instead.

The AST here consists of Number s, String s, and List s, or the special case Error for invalid parse results. Each of these types implements the AST interface which allows casting to those types for easy unwrapping. To convert a shirakumo.org/markless/component/Component to such an AST, simply call Convert.

Also included is a parser for the standard test suite format of this AST, used by the Markless test suite. The entry point for this is simply Parse.

Index

Variables

var Err = Error{}

Types

type AST

type AST interface {
	IsNumber() bool
	IsString() bool
	IsList() bool
	IsError() bool
	AsNumber() float32
	AsString() string
	AsList() []AST
	String() string
}

func Convert

func Convert(c components.Component) AST

func Parse

func Parse(in string) AST

type Error

type Error struct{}

func (*Error) AsList

func (a *Error) AsList() []AST

func (*Error) AsNumber

func (a *Error) AsNumber() float32

func (*Error) AsString

func (a *Error) AsString() string

func (*Error) IsError

func (a *Error) IsError() bool

func (*Error) IsList

func (a *Error) IsList() bool

func (*Error) IsNumber

func (a *Error) IsNumber() bool

func (*Error) IsString

func (a *Error) IsString() bool

func (*Error) String

func (a *Error) String() string

type List

type List []AST

func (*List) AsList

func (a *List) AsList() []AST

func (*List) AsNumber

func (a *List) AsNumber() float32

func (*List) AsString

func (a *List) AsString() string

func (*List) IsError

func (a *List) IsError() bool

func (*List) IsList

func (a *List) IsList() bool

func (*List) IsNumber

func (a *List) IsNumber() bool

func (*List) IsString

func (a *List) IsString() bool

func (*List) String

func (a *List) String() string

type Number

type Number float32

func (*Number) AsList

func (a *Number) AsList() []AST

func (*Number) AsNumber

func (a *Number) AsNumber() float32

func (*Number) AsString

func (a *Number) AsString() string

func (*Number) IsError

func (a *Number) IsError() bool

func (*Number) IsList

func (a *Number) IsList() bool

func (*Number) IsNumber

func (a *Number) IsNumber() bool

func (*Number) IsString

func (a *Number) IsString() bool

func (*Number) String

func (a *Number) String() string

type String

type String string

func (*String) AsList

func (a *String) AsList() []AST

func (*String) AsNumber

func (a *String) AsNumber() float32

func (*String) AsString

func (a *String) AsString() string

func (*String) IsError

func (a *String) IsError() bool

func (*String) IsList

func (a *String) IsList() bool

func (*String) IsNumber

func (a *String) IsNumber() bool

func (*String) IsString

func (a *String) IsString() bool

func (*String) String

func (a *String) String() string