bali

package
v0.0.0-...-1318f34 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 FormatEntity

func FormatEntity(entity abs.Entity) string

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

func Formatter

func Formatter(indentation int) *formatter

This constructor creates a new formatter using the specified indentation.

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/craterdog-bali/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 ParseSource

func ParseSource(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 Parser

func Parser(source []byte) *parser

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

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/craterdog-bali/bali-nebula/wiki/Language-Specification

All token types in the specification are shown in UPPERCASE.

Types

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
	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