parser

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGolangTypes

func GenerateGolangTypes(t TLB) (string, error)

Types

type Anon

type Anon struct {
	Values []FieldDefinition `"[" @@ "]"`
}

type CellRef

type CellRef struct {
	TypeExpression TypeExpression `"^" @@`
}

type Combinator

type Combinator struct {
	Name            string           `@Ident`
	TypeExpressions []TypeExpression `@@*`
}

func (Combinator) String

func (c Combinator) String() string

type CombinatorDeclaration

type CombinatorDeclaration struct {
	Constructor      Constructor        `@@`
	FieldDefinitions []*FieldDefinition `@@*`
	Equal            string             `"="`
	Combinator       Combinator         `@@`
	End              string             `";"`
}

type Constructor

type Constructor struct {
	Name   string `@Ident`
	Prefix string `@(HexTag|BinTag)?`
}

type FieldDefinition

type FieldDefinition struct {
	Implicit   *ImplicitDefinition `@@`
	NamedField *NamedField         `| @@`
	CellRef    *CellRef            `| @@`
}

type ImplicitDefinition

type ImplicitDefinition struct {
	Start      string          `"{"`
	Implicit   *ImplicitField  `(@@`
	Expression *TypeExpression `| @@)`
	End        string          `"}"`
}

type ImplicitField

type ImplicitField struct {
	Name string `@Ident`
	Sep  string `":"`
	Type string `@("#"|"Type")`
}

type NamedField

type NamedField struct {
	Name       string         `@(Ident|"_")`
	Sep        string         `":"`
	Expression TypeExpression `@@`
}

type ParenExpression

type ParenExpression struct {
	Name      TypeExpression   `"(" @@ `
	Parameter []TypeExpression `@@* ")"`
}

type TLB

type TLB struct {
	Declarations []*CombinatorDeclaration `@@*`
}

func Parse

func Parse(tlb string) (*TLB, error)

type TypeExpression

type TypeExpression struct {
	Tilda                string           `@"~"?`
	ParenExpression      *ParenExpression `@@`
	AnonymousConstructor *Anon            `| @@`
	CellRef              *CellRef         `| @@`
	BuiltIn              *string          `| @BuiltIn`
	NUMBER               *string          `| @NUMBER`
	NamedRef             *string          `| @Ident`
}

func (TypeExpression) String

func (t TypeExpression) String() string

Jump to

Keyboard shortcuts

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