Documentation ¶
Index ¶
- func FormatComponent(component abs.ComponentLike) string
- func FormatComponentWithIndentation(component abs.ComponentLike, indentation int) string
- func FormatEntity(entity abs.Entity) string
- func Formatter(indentation int) *formatter
- func ParseDocument(document []byte) abs.ComponentLike
- func ParseSource(source string) abs.ComponentLike
- func Parser(source []byte) *parser
- func Scanner(source []byte, tokens chan Token) *scanner
- type Token
- type TokenType
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 ¶
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 ¶
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.
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.