bali

package
v0.0.0-...-d9996d1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOL = "\n" // The POSIX end of line character.
)

Variables

This section is empty.

Functions

func Angle

func Angle(value abs.Value) abs.AngleLike

This constructor returns a new angle element initialized with the specified value.

func Binary

func Binary(value abs.Value) abs.BinaryLike

This constructor returns a new binary string initialized with the specified value.

func Boolean

func Boolean(value abs.Value) abs.BooleanLike

This constructor returns a new boolean element initialized with the specified value.

func Bytecode

func Bytecode(value abs.Value) abs.BytecodeLike

This constructor returns a new bytecode string initialized with the specified value.

func Catalog

func Catalog(source string) abs.CatalogLike

This function parses a catalog from a source string.

func CatalogWithContext

func CatalogWithContext(associations Associations, context abs.ContextLike) abs.ComponentLike

This constructor returns a new catalog component initialized with the specified associations and parameterized with the specified context.

func Component

func Component(value abs.Value) abs.ComponentLike

This constructor returns a new component initialized with the specified value.

func ComponentWithContext

func ComponentWithContext(value abs.Value, context abs.ContextLike) abs.ComponentLike

This constructor returns a new component initialized with the specified value and context.

func Context

func Context(value abs.Value) abs.ContextLike

This constructor returns a new context initialized with the specified value.

func Continuum

func Continuum(first abs.Value, extent abs.Extent, last abs.Value, context abs.ContextLike) abs.ComponentLike

This constructor returns a new continuous range with the specified endpoints.

func Duration

func Duration(value abs.Value) abs.DurationLike

This constructor returns a new duration element initialized with the specified value.

func FormatComponent

func FormatComponent(component abs.ComponentLike) string

This function returns a canonical BDN string for the specified component.

func FormatComponentWithIndentation

func FormatComponentWithIndentation(component abs.ComponentLike, indentation int) string

This function returns a canonical BDN string for the specified component using the specified indentation.

func FormatDocument

func FormatDocument(component abs.ComponentLike) []byte

This function returns a canonical BDN bytes for the specified component including the POSIX standard trailing EOL.

func FormatEntity

func FormatEntity(entity abs.Entity) string

This function returns a canonical BDN string for the specified entity.

func FormatEntityWithIndentation

func FormatEntityWithIndentation(entity abs.Entity, indentation int) string

This function returns a canonical BDN string for the specified entity using the specified indentation.

func FormatGrammar

func FormatGrammar() string

func Formatter

func Formatter(indentation int) *formatter

This constructor creates a new formatter using the specified indentation.

func Integer

func Integer(value abs.Value) abs.IntegerLike

This constructor returns a new integer endpoint with the specified value.

func Interval

func Interval(first abs.Value, extent abs.Extent, last abs.Value, context abs.ContextLike) abs.ComponentLike

This constructor returns a new continuous range with the specified endpoints. This constructor returns a new discrete range with the specified endpoints.

func List

func List(source string) abs.ListLike

This function parses a catalog from a source string.

func ListWithContext

func ListWithContext(components Components, context abs.ContextLike) abs.ComponentLike

This constructor returns a new list component initialized with the specified associations and parameterized with the specified context.

func Moment

func Moment(value abs.Value) abs.MomentLike

This constructor returns a new moment element initialized with the specified value.

func Moniker

func Moniker(value abs.Value) abs.MonikerLike

This constructor returns a new moniker string initialized with the specified value.

func Narrative

func Narrative(value abs.Value) abs.NarrativeLike

This constructor returns a new narrative string initialized with the specified value.

func NewTag

func NewTag() abs.TagLike

This constructor returns a new random tag element of the default size.

func NextVersion

func NextVersion(current abs.VersionLike) abs.VersionLike

This constructor returns the next version string for the specified version.

func Number

func Number(value abs.Value) abs.NumberLike

This constructor returns a new number element initialized with the specified value.

func ParseComponent

func ParseComponent(source string) abs.ComponentLike

This function parses a source string rather than the bytes from a BDN document file. It is useful when parsing strings within source code.

func ParseContext

func ParseContext(source string) abs.ContextLike

This function parses an entity from a source string.

func ParseDocument

func ParseDocument(document []byte) abs.ComponentLike

This function parses the specified Bali Document Notation™ (BDN) source bytes retrieved from a POSIX compliant file and returns the corresponding abstract syntax tree as defined in the language specification:

https://github.com/bali-nebula/bali-nebula/wiki/Language-Specification

All parser rules in the specification are shown in lowerCamelCase and scanner tokens shown in UPPERCASE.

A POSIX compliant file must end with a EOL character before the EOF marker.

func ParseEntity

func ParseEntity(source string) abs.Entity

This function parses an entity from a source string.

func Parser

func Parser(source []byte) *parser

This constructor creates a new parser using the specified byte array.

func Pattern

func Pattern(value abs.Value) abs.PatternLike

This constructor returns a new pattern element initialized with the specified value.

func Percentage

func Percentage(value abs.Value) abs.PercentageLike

This constructor returns a new percentage element initialized with the specified value.

func Probability

func Probability(value abs.Value) abs.ProbabilityLike

This constructor returns a new probability element initialized with the specified value.

func Queue

func Queue(source string) abs.QueueLike

This function parses a catalog from a source string.

func QueueWithContext

func QueueWithContext(capacity int, context abs.ContextLike) abs.ComponentLike

This constructor returns a new queue component with the specified capacity and parameterized with the specified context.

func Quote

func Quote(value abs.Value) abs.QuoteLike

This constructor returns a new quote string initialized with the specified value.

func Real

func Real(value abs.Value) abs.RealLike

This constructor returns a new real endpoint with the specified value.

func Resource

func Resource(value abs.Value) abs.ResourceLike

This constructor returns a new resource element initialized with the specified value.

func Rune

func Rune(value abs.Value) abs.RuneLike

This constructor returns a new rune endpoint with the specified value.

func Scanner

func Scanner(source []byte, tokens chan Token) *scanner

This constructor creates a new scanner initialized with the specified array of bytes. The scanner will scan in tokens matching Bali Document Notation™ as defined in the language specification:

https://github.com/bali-nebula/bali-nebula/wiki/Language-Specification

All token types in the specification are shown in UPPERCASE.

func Set

func Set(source string) abs.SetLike

This function parses a catalog from a source string.

func SetWithContext

func SetWithContext(components Components, context abs.ContextLike) abs.ComponentLike

This constructor returns a new set component initialized with the specified associations and parameterized with the specified context.

func Spectrum

func Spectrum(first abs.Value, extent abs.Extent, last abs.Value, context abs.ContextLike) abs.ComponentLike

This constructor returns a new lexical range with the specified endpoints.

func Stack

func Stack(source string) abs.StackLike

This function parses a catalog from a source string.

func StackWithContext

func StackWithContext(capacity int, context abs.ContextLike) abs.ComponentLike

This constructor returns a new stack component with the specified capacity and parameterized with the specified context.

func Symbol

func Symbol(value abs.Value) abs.SymbolLike

This constructor returns a new symbol element initialized with the specified value.

func Tag

func Tag(value abs.Value) abs.TagLike

This constructor returns a new tag element initialized with the specified value.

func Version

func Version(value abs.Value) abs.VersionLike

This constructor returns a new version string initialized with the specified value.

Types

type Associations

type Associations [][2]any

type Components

type Components []any

type Token

type Token struct {
	Type     TokenType
	Value    string
	Line     int // The line number of the token in the input string.
	Position int // The position in the line of the first rune of the token.
}

This type defines the structure and methods for each token returned by the scanner.

func (Token) String

func (v Token) String() string

This method returns the a canonical string version of this token.

type TokenType

type TokenType int

This integer type is used as a type identifier for each token.

const (
	// The first two token types must be first.
	TokenError TokenType = iota
	TokenEOF
	TokenEOL
	TokenAngle
	TokenBinary
	TokenBoolean
	TokenBytecode
	TokenComment
	TokenDelimiter
	TokenDuration
	TokenIdentifier
	TokenKeyword
	TokenMoment
	TokenMoniker
	TokenNarrative
	TokenNote
	TokenNumber
	TokenPattern
	TokenPercentage
	TokenProbability
	TokenQuote
	TokenResource
	TokenSymbol
	TokenTag
	TokenVersion
)

This enumeration defines all possible token types including the error token.

func (TokenType) String

func (v TokenType) String() string

This method returns the string representation for each token type.

Jump to

Keyboard shortcuts

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