parser

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBitsTypes added in v1.0.1

func GenerateBitsTypes(sizes []int) string

func GenerateConstantBigInts added in v1.0.1

func GenerateConstantBigInts(sizes []int) string

func GenerateConstantInts added in v1.0.1

func GenerateConstantInts(max int) string

func GenerateVarUintTypes added in v1.0.1

func GenerateVarUintTypes(max int) string

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 `@@*`
}

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 DefaultType added in v1.0.1

type DefaultType struct {
	Name          string
	IsPointerType bool
}

type FieldDefinition

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

func (FieldDefinition) IsEmpty added in v1.0.1

func (fd FieldDefinition) IsEmpty() bool

type Generator added in v1.0.1

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator added in v1.0.1

func NewGenerator(knownTypes map[string]DefaultType, typeName string) *Generator

func (*Generator) GenerateGolangTypes added in v1.0.1

func (g *Generator) GenerateGolangTypes(declarations []CombinatorDeclaration, typePrefix string, skipMagic bool) (string, error)

func (*Generator) GetTlbTypes added in v1.0.1

func (g *Generator) GetTlbTypes() []TlbType

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 Optional added in v1.0.1

type Optional struct {
	Modificator string `@Ident`
	Dot         string `"."`
	Int         int    `@NUMBER`
	QMark       string `"?"`
	Ident       string `@Ident`
}

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 TlbType added in v1.0.1

type TlbType struct {
	Name       string
	Definition string
}

type TypeExpression

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

Jump to

Keyboard shortcuts

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