lang

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit added in v0.48.0

func Emit(blueprint *schema.Blueprint) (string, error)

Emit serialises a blueprint model into blueprint language (.bp) source text. Every top-level construct (version, transform, variables, values, includes, resources, datasources and exports) is supported.

func ParseFile

func ParseFile(path string) (*schema.Blueprint, error)

ParseFile reads a .blueprint / .bp file and returns a standardised blueprint model. This returns a structured error with source positions on any parse failures.

func ParseString

func ParseString(src string) (*schema.Blueprint, error)

ParseString parses a blueprint language source string and returns a standardised blueprint model. This returns a structured error with source positions on any parse failures.

Types

type Errors

type Errors struct {
	ChildErrors []error
	// Source is the original blueprint-language source. Optional; when set,
	// Error() renders a source-snippet under each child diagnostic.
	Source string
}

Errors aggregates the diagnostics collected across lexing and parsing into a single returnable error. When Source is non-empty, each child error is rendered with a source snippet showing the offending line and a caret column-aligned under the column the error points at.

func (*Errors) Error

func (e *Errors) Error() string

type LexError

type LexError struct {
	Message    string
	SourceMeta *source.Meta
}

LexError represents a single error encountered during lexing, with a message and source position.

func (*LexError) Error

func (e *LexError) Error() string

type LexErrors

type LexErrors struct {
	Message     string
	ChildErrors []error
}

LexErrors represents multiple errors encountered during lexing, with a message and a list of child errors.

func (*LexErrors) Error

func (e *LexErrors) Error() string

type ParseError

type ParseError struct {
	Message    string
	SourceMeta *source.Meta
}

ParseError represents a single error encountered during parsing, with a message and source position.

func (*ParseError) Error

func (e *ParseError) Error() string

type Token

type Token struct {
	Type  TokenType
	Value string
	Start source.Position
	End   source.Position
}

Token is a single lexical token carrying its source position range. Start is inclusive and End is exclusive (the position immediately after the token's final rune).

func Tokenize

func Tokenize(src string) ([]Token, error)

Tokenize lexes a blueprint language source string into its full token stream, terminated by a single TokenEOF token. Unlike ParseString, the stream preserves comments and newlines, so callers such as a language server can reconstruct a concrete syntax tree for features like completion and document symbols.

The token slice is always returned, even on lexical errors. This allows a partial CST to be built for an in-progress edit. Any lexical errors are aggregated into the returned error, which is a *Errors envelope (the same type ParseString returns) or nil when lexing succeeds.

type TokenType

type TokenType string

TokenType identifies the kind of a lexical Token produced by the lexer.

const (
	TokenLeftBracket            TokenType = "leftBracket"
	TokenRightBracket           TokenType = "rightBracket"
	TokenLeftParen              TokenType = "leftParen"
	TokenRightParen             TokenType = "rightParen"
	TokenLeftBrace              TokenType = "leftBrace"
	TokenRightBrace             TokenType = "rightBrace"
	TokenColon                  TokenType = "colon"
	TokenAssign                 TokenType = "assign"
	TokenComma                  TokenType = "comma"
	TokenPeriod                 TokenType = "period"
	TokenEq                     TokenType = "eq"
	TokenNeq                    TokenType = "neq"
	TokenLt                     TokenType = "lt"
	TokenGt                     TokenType = "gt"
	TokenLte                    TokenType = "lte"
	TokenGte                    TokenType = "gte"
	TokenAnd                    TokenType = "and"
	TokenOr                     TokenType = "or"
	TokenNot                    TokenType = "not"
	TokenSlash                  TokenType = "slash"
	TokenStar                   TokenType = "star"
	TokenIntLiteral             TokenType = "intLiteral"
	TokenFloatLiteral           TokenType = "floatLiteral"
	TokenBoolLiteral            TokenType = "boolLiteral"
	TokenNoneLiteral            TokenType = "noneLiteral"
	TokenStringStart            TokenType = "stringStart"
	TokenStringEnd              TokenType = "stringEnd"
	TokenStringLiteral          TokenType = "stringLiteral"
	TokenMultilineStringLiteral TokenType = "multilineStringLiteral"
	TokenInterpolationStart     TokenType = "interpolationStart"
	TokenInterpolationEnd       TokenType = "interpolationEnd"
	TokenNewline                TokenType = "newline"
	TokenComment                TokenType = "comment"
	TokenIdent                  TokenType = "identifier"
	TokenKeywordVariables       TokenType = "keywordVariables"
	TokenKeywordValues          TokenType = "keywordValues"
	TokenKeywordDatasources     TokenType = "keywordDatasources"
	TokenKeywordResources       TokenType = "keywordResources"
	TokenKeywordChildren        TokenType = "keywordChildren"
	TokenKeywordElem            TokenType = "keywordElem"
	TokenKeywordI               TokenType = "keywordI"
	TokenKeywordVariable        TokenType = "keywordVariable"
	TokenKeywordValue           TokenType = "keywordValue"
	TokenKeywordData            TokenType = "keywordData"
	TokenKeywordResource        TokenType = "keywordResource"
	TokenKeywordInclude         TokenType = "keywordInclude"
	TokenKeywordExport          TokenType = "keywordExport"
	TokenKeywordMetadata        TokenType = "keywordMetadata"
	TokenKeywordSpec            TokenType = "keywordSpec"
	TokenKeywordSelect          TokenType = "keywordSelect"
	TokenKeywordFilter          TokenType = "keywordFilter"
	TokenKeywordForeach         TokenType = "keywordForeach"
	TokenKeywordAs              TokenType = "keywordAs"
	TokenKeywordBy              TokenType = "keywordBy"
	TokenKeywordLabel           TokenType = "keywordLabel"
	TokenKeywordVersion         TokenType = "keywordVersion"
	TokenKeywordTransform       TokenType = "keywordTransform"
	TokenKeywordNot             TokenType = "keywordNot"
	TokenKeywordIn              TokenType = "keywordIn"
	TokenKeywordHas             TokenType = "keywordHas"
	TokenKeywordKey             TokenType = "keywordKey"
	TokenKeywordContains        TokenType = "keywordContains"
	TokenKeywordStarts          TokenType = "keywordStarts"
	TokenKeywordWith            TokenType = "keywordWith"
	TokenKeywordEnds            TokenType = "keywordEnds"
	TokenKeywordString          TokenType = "keywordString"
	TokenKeywordInteger         TokenType = "keywordInteger"
	TokenKeywordFloat           TokenType = "keywordFloat"
	TokenKeywordBoolean         TokenType = "keywordBoolean"
	TokenKeywordArray           TokenType = "keywordArray"
	TokenKeywordObject          TokenType = "keywordObject"
	TokenEOF                    TokenType = "eof"
)

Token kinds produced by the lexer. Consumers building a concrete syntax tree from the token stream (e.g. a language server) will use these.

func (TokenType) String

func (tt TokenType) String() string

String returns a human-friendly label for use in diagnostics: the literal symbol for punctuation/operators, `keyword "x"` for reserved words, and a category name for value-bearing or structural tokens.

Jump to

Keyboard shortcuts

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