Skip to content

package syntax

import "github.com/cloudboss/unobin/pkg/lang/syntax"

Functions

func ValidateFile

func ValidateFile(f *File) *parse.ErrorList

Types

type CompositeDecl

type CompositeDecl struct {
    S    parse.Span
    Name Ident
    Kind NodeKind
    Body FactoryBody
}

type ConstraintDecl

type ConstraintDecl struct {
    S     parse.Span
    Value parse.Expr
}

type EncryptionDecl

type EncryptionDecl struct {
    S        parse.Span
    Selector Ident
    Body     *parse.ObjectLit
}

type FactoryBody

type FactoryBody struct {
    S              parse.Span
    Description    *parse.StringLit
    Inputs         []InputDecl
    Locals         []LocalDecl
    Constraints    []ConstraintDecl
    Imports        []ImportDecl
    LibraryConfigs []LibraryConfigDecl
    StateMoves     []StateMoveDecl
    Resources      []NodeDecl
    Data           []NodeDecl
    Actions        []NodeDecl
    Outputs        []OutputDecl
}

type FactoryFile

type FactoryFile struct {
    S    parse.Span
    Body FactoryBody
}

type File

type File struct {
    S           parse.Span
    Kind        FileKind
    Path        string
    Factory     *FactoryFile
    Stack       *StackFile
    Project     *ProjectFile
    ProjectLock *ProjectLockFile
    Library     *LibraryFile
    Comments    []parse.Comment
}

func LowerFile

func LowerFile(f *parse.File) (*File, *parse.ErrorList)

func LowerParsedSource

func LowerParsedSource(path string, src []byte, f *lang.File) (*File, error)

LowerParsedSource lowers an already parsed UB source file into typed syntax.

func ParseSource

func ParseSource(path string, b []byte) (*File, error)

type FileKind

type FileKind int

type Ident

type Ident struct {
    S    parse.Span
    Name string
}

type ImportDecl

type ImportDecl struct {
    S     parse.Span
    Alias Ident
    Ref   *parse.StringLit
}

type InputDecl

type InputDecl struct {
    S    parse.Span
    Name Ident
    Body *parse.ObjectLit
    Type parse.TypeExpr
}

type LibraryConfigDecl

type LibraryConfigDecl struct {
    S     parse.Span
    Alias Ident
    Value parse.Expr
}

type LibraryFile

type LibraryFile struct {
    S       parse.Span
    Exports []CompositeDecl
}

type LocalDecl

type LocalDecl struct {
    S     parse.Span
    Name  Ident
    Value parse.Expr
}

type NodeDecl

type NodeDecl struct {
    S        parse.Span
    Kind     NodeKind
    Name     Ident
    Selector NodeSelector
    Body     *parse.ObjectLit
}

type NodeKind

type NodeKind string

type NodeSelector

type NodeSelector struct {
    S      parse.Span
    Alias  Ident
    Export Ident
}

type OutputDecl

type OutputDecl struct {
    S    parse.Span
    Name Ident
    Body *parse.ObjectLit
}

type ProjectFile

type ProjectFile struct {
    S             parse.Span
    UnobinVersion *parse.StringLit
    Requires      []ProjectRequire
    Replace       []ProjectReplace
}

type ProjectLockDep

type ProjectLockDep struct {
    S       parse.Span
    ID      StringKey
    Kind    Ident
    Version *parse.StringLit
    Commit  *parse.StringLit
    Hash    *parse.StringLit
}

type ProjectLockFile

type ProjectLockFile struct {
    S         parse.Span
    Version   *parse.NumberLit
    Toolchain *ProjectLockToolchain
    Deps      []ProjectLockDep
}

type ProjectLockToolchain

type ProjectLockToolchain struct {
    S             parse.Span
    UnobinVersion *parse.StringLit
}

type ProjectReplace

type ProjectReplace struct {
    S    parse.Span
    ID   StringKey
    Path *parse.StringLit
}

type ProjectRequire

type ProjectRequire struct {
    S        parse.Span
    ID       StringKey
    Version  *parse.StringLit
    Indirect *parse.BoolLit
}

type SourceFileSpec

type SourceFileSpec struct {
    DisplayPath    string
    LibraryPath    string
    ProjectRelPath string
    PackageRelPath string
    LineStarts     []int
}

type StackFactoryBlock

type StackFactoryBlock struct {
    S      parse.Span
    Pin    *parse.ObjectLit
    Inputs *parse.ObjectLit
}

type StackFile

type StackFile struct {
    S           parse.Span
    Factory     *StackFactoryBlock
    State       *StateDecl
    Encryption  *EncryptionDecl
    Locals      []LocalDecl
    Parallelism parse.Expr
}

type StateDecl

type StateDecl struct {
    S        parse.Span
    Selector Ident
    Body     *parse.ObjectLit
}

type StateMoveDecl

type StateMoveDecl struct {
    S    parse.Span
    From *StateMoveRef
    To   *StateMoveRef
}

type StateMoveRef

type StateMoveRef struct {
    S   parse.Span
    Ref stateref.EntryRef
}

type StringKey

type StringKey struct {
    S     parse.Span
    Value string
}