ast

package
v0.0.0-...-6f11ea9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Pos   token.Position
	Rules []GroupEntry
}

func (*Array) End

func (a *Array) End() token.Position

func (*Array) Start

func (a *Array) Start() token.Position

type BadNode

type BadNode struct {
	// The start position of the bad node
	Pos token.Position

	// The position of the triggering token
	Token token.Token

	// The base node of the bad node
	Base Node

	// The end position
	EndPos token.Position
}

BadNode represents a node formed due to parsing error

func (*BadNode) End

func (b *BadNode) End() token.Position

End returns the estimated end of the bad node

func (*BadNode) Start

func (b *BadNode) Start() token.Position

Start returns the start if the base node

type Bits

type Bits struct {
	// Pos: the position of the .size token
	Pos token.Position

	// Token: the token responsible for the node
	Token token.Token

	// Base: the base node
	Base Node

	// Constraint: the bits constraint to apply
	Contstraint Node
}

Bits represents the AST Node for `.bits` control operator

func (*Bits) End

func (r *Bits) End() token.Position

func (*Bits) Start

func (r *Bits) Start() token.Position

type BooleanLiteral

type BooleanLiteral struct {
	Range token.PositionRange
	Bool  bool
}

func (*BooleanLiteral) End

func (bl *BooleanLiteral) End() token.Position

func (*BooleanLiteral) Start

func (bl *BooleanLiteral) Start() token.Position

type BooleanType

type BooleanType struct {
	Pos   token.Position
	Token token.Token
}

BooleanType represents the AST Node for the `bool` type definition token.

func (*BooleanType) End

func (b *BooleanType) End() token.Position

func (*BooleanType) Start

func (b *BooleanType) Start() token.Position

type BstrType

type BstrType struct {
	Pos   token.Position
	Token token.Token
}

BstrType represents the AST Node for the `bstr` type definition token.

func (*BstrType) End

func (b *BstrType) End() token.Position

func (*BstrType) Start

func (b *BstrType) Start() token.Position

type BytesType

type BytesType struct {
	Pos   token.Position
	Token token.Token
}

BytesType represents the AST Node for the `bytes` type definition token.

func (*BytesType) End

func (b *BytesType) End() token.Position

func (*BytesType) Start

func (b *BytesType) Start() token.Position

type CDDL

type CDDL struct {
	Pos   token.Position
	Rules []CDDLEntry
}

File Node represents a cddl source file

func (*CDDL) End

func (c *CDDL) End() token.Position

func (*CDDL) Start

func (c *CDDL) Start() token.Position

func (*CDDL) String

func (c *CDDL) String() string

type CDDLEntry

type CDDLEntry interface {
	Node
	// contains filtered or unexported methods
}

type Comment

type Comment struct {
	Pos  token.Position
	Text string
}

Comment represents the AST Node for ;-style single line comment.

func (*Comment) End

func (c *Comment) End() token.Position

func (*Comment) Start

func (c *Comment) Start() token.Position

type CommentGroup

type CommentGroup struct {
	List []*Comment
}

CommentGroup represents a sequence of comments with no empty lines

func (*CommentGroup) End

func (cg *CommentGroup) End() token.Position

func (*CommentGroup) Start

func (cg *CommentGroup) Start() token.Position

func (*CommentGroup) String

func (cg *CommentGroup) String() (out string)

type ComparatorOpControl

type ComparatorOpControl struct {
	Pos         token.Position
	Token       token.Token
	Operator    string
	Left, Right Node
}

ControlOpControl represents the AST Node for operators `.lt, .le, .gt, .ge, .eq, .ne` with numeric left and right values. This also takes identifiers that resolve to numeric types.

Numeric values are: `int, uint, nint, float, float16, float32, float64`

func (*ComparatorOpControl) End

func (*ComparatorOpControl) Start

func (cc *ComparatorOpControl) Start() token.Position

type Entry

type Entry struct {
	Pos             token.Position
	Name            *Identifier
	Value           Node
	TrailingComment *Comment
}

Entry represents the Node for a group entry It maps the name of the type to the type

func (*Entry) End

func (r *Entry) End() token.Position

func (*Entry) Start

func (r *Entry) Start() token.Position

type Enumeration

type Enumeration struct {
	Pos   token.Position
	Token token.Token
	Value Node
}

func (*Enumeration) End

func (e *Enumeration) End() token.Position

func (*Enumeration) Start

func (e *Enumeration) Start() token.Position

type FloatLiteral

type FloatLiteral struct {
	Range   token.PositionRange
	Token   token.Token
	Literal float64
}

FloatLiteral represesnts the AST Node for float type token i.e. 3.412

func (*FloatLiteral) End

func (fl *FloatLiteral) End() token.Position

func (*FloatLiteral) Start

func (fl *FloatLiteral) Start() token.Position

type FloatType

type FloatType struct {
	Pos   token.Position
	Token token.Token
	Base  int // 16, 32, 64
}

FloatType represents the AST Node for `float, float16, float32, float64` type definition tokens.

func (*FloatType) End

func (ft *FloatType) End() token.Position

func (*FloatType) Start

func (ft *FloatType) Start() token.Position

type Group

type Group struct {
	Pos     token.Position
	Entries []GroupEntry
}

func (*Group) End

func (g *Group) End() token.Position

func (*Group) Start

func (g *Group) Start() token.Position

type GroupChoice

type GroupChoice struct {
	Pos           token.Position
	Token         token.Token
	First, Second Node
}

func (*GroupChoice) End

func (gc *GroupChoice) End() token.Position

func (*GroupChoice) Start

func (gc *GroupChoice) Start() token.Position

type GroupEntry

type GroupEntry interface {
	Node
	// contains filtered or unexported methods
}

type Identifier

type Identifier struct {
	Pos  token.Position
	Name string
}

Identifer represents the AST Node for named identifiers

func (*Identifier) End

func (i *Identifier) End() token.Position

func (*Identifier) IsPlug

func (i *Identifier) IsPlug() bool

func (*Identifier) IsSocket

func (i *Identifier) IsSocket() bool

func (*Identifier) Start

func (i *Identifier) Start() token.Position

func (*Identifier) String

func (i *Identifier) String() string

type IntegerLiteral

type IntegerLiteral struct {
	Pos     token.Position
	Token   token.Token
	Literal int64
}

IntegerLiteral represents the AST Node for an integer literal i.e 3

func (*IntegerLiteral) End

func (il *IntegerLiteral) End() token.Position

func (*IntegerLiteral) Start

func (il *IntegerLiteral) Start() token.Position

type IntegerType

type IntegerType struct {
	Pos   token.Position
	Token token.Token
}

IntegerType represents the AST Node for the `int` type decalration token

func (*IntegerType) End

func (it *IntegerType) End() token.Position

func (*IntegerType) Start

func (it *IntegerType) Start() token.Position

type Map

type Map struct {
	Pos   token.Position
	Token token.Token
	Rules []Node
}

func (*Map) End

func (m *Map) End() token.Position

func (*Map) Start

func (m *Map) Start() token.Position

type NMOccurrence

type NMOccurrence struct {
	Pos   token.Position
	Token token.Token
	N, M  *UintLiteral
	Item  Node
}

func (*NMOccurrence) End

func (nm *NMOccurrence) End() token.Position

func (*NMOccurrence) Start

func (nm *NMOccurrence) Start() token.Position

type NegativeIntegerType

type NegativeIntegerType struct {
	Pos   token.Position
	Token token.Token
}

func (*NegativeIntegerType) End

func (*NegativeIntegerType) Start

func (nt *NegativeIntegerType) Start() token.Position

type Node

type Node interface {
	// Start returns the start token of the node
	Start() token.Position

	// End returns the end token of the node
	End() token.Position
}

Node interface represents an AST Node

type NullType

type NullType struct {
	Pos   token.Position
	Token token.Token
}

NullType represents the AST Node for the `null` and `nil` tokens

func (*NullType) End

func (nt *NullType) End() token.Position

func (*NullType) Start

func (nt *NullType) Start() token.Position

type Optional

type Optional struct {
	Pos   token.Position
	Token token.Token
	Item  Node
}

Optional represents the AST Node for the `?` prefixed optional entry

func (*Optional) End

func (i *Optional) End() token.Position

func (*Optional) Start

func (i *Optional) Start() token.Position

type Range

type Range struct {
	Pos      token.Position
	Token    token.Token
	From, To Node
}

Range represents the AST Node for `..` and `...` range definition tokens.

func (*Range) End

func (r *Range) End() token.Position

End returns the last position of the node

func (*Range) Start

func (r *Range) Start() token.Position

Start returns the start of the node

type Regexp

type Regexp struct {
	Pos   token.Position
	Token token.Token
	Base  *TstrType
	Regex Node
}

Regexp represents the AST Node for `.regexp` control operator

func (*Regexp) End

func (r *Regexp) End() token.Position

func (*Regexp) Start

func (r *Regexp) Start() token.Position

type Rule

type Rule struct {
	Pos             token.Position
	Name            *Identifier
	Value           Node
	TrailingComment *Comment
}

Rule represents the AST Node for typed identifer. It maps the name of the type to the type

func (*Rule) End

func (r *Rule) End() token.Position

func (*Rule) Start

func (r *Rule) Start() token.Position

type SizeOperatorControl

type SizeOperatorControl struct {
	// Pos: the position of the .size token
	Pos token.Position

	// Token: the token responsible for the node
	Token token.Token

	// Size: number of bytes
	Size Node

	// Type: the base type to apply the contraint to
	Type Node
}

SizeOperatorControl represents the AST Node for `.size` control operator

func (*SizeOperatorControl) End

End returns the end of the size

func (*SizeOperatorControl) Start

func (sc *SizeOperatorControl) Start() token.Position

Start returns the start of the base type

type Tag

type Tag struct {
	Pos              token.Position
	Token            token.Token
	Major, TagNumber *UintLiteral
	Item             Node
}

func (*Tag) End

func (t *Tag) End() token.Position

func (*Tag) Start

func (t *Tag) Start() token.Position

type TextLiteral

type TextLiteral struct {
	Pos     token.Position
	Token   token.Token
	Literal string
}

TextLiteral represents the AST Node for a text literal

func (*TextLiteral) End

func (tl *TextLiteral) End() token.Position

func (*TextLiteral) Start

func (tl *TextLiteral) Start() token.Position

type TstrType

type TstrType struct {
	Pos   token.Position
	Token token.Token
}

TstrType represents the AST Node for the `tstr` type definition token

func (*TstrType) End

func (tt *TstrType) End() token.Position

func (*TstrType) Start

func (tt *TstrType) Start() token.Position

type TypeChoice

type TypeChoice struct {
	Pos           token.Position
	Token         token.Token
	First, Second Node
}

TypeChoice represents the AST Node for `/` type choice operator

func (*TypeChoice) End

func (tc *TypeChoice) End() token.Position

func (*TypeChoice) Start

func (tc *TypeChoice) Start() token.Position

type UintLiteral

type UintLiteral struct {
	Pos     token.Position
	Token   token.Token
	Literal uint64
}

IntegerLiteral represents the AST Node for an integer literal i.e 3

func (*UintLiteral) End

func (ul *UintLiteral) End() token.Position

func (*UintLiteral) Start

func (ul *UintLiteral) Start() token.Position

type UintType

type UintType struct {
	Range token.PositionRange
	Token token.Token
}

UintType represents the AST Node for `uint` data definition type

func (*UintType) End

func (ut *UintType) End() token.Position

func (*UintType) Start

func (ut *UintType) Start() token.Position

type Unwrap

type Unwrap struct {
	Pos   token.Position
	Token token.Token
	Item  Node
}

func (*Unwrap) End

func (u *Unwrap) End() token.Position

func (*Unwrap) Start

func (u *Unwrap) Start() token.Position

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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