ast

package
v0.0.0-...-a1a6cd4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTBlock

type ASTBlock struct {
	Statements []IASTItem
}

func NewASTBlock

func NewASTBlock(statements []IASTItem) *ASTBlock

func (*ASTBlock) EndsWithBreak

func (b *ASTBlock) EndsWithBreak() bool

func (*ASTBlock) EndsWithReturn

func (b *ASTBlock) EndsWithReturn() bool

func (*ASTBlock) IsEmpty

func (b *ASTBlock) IsEmpty() bool

func (*ASTBlock) String

func (b *ASTBlock) String() string

func (*ASTBlock) StringInner

func (b *ASTBlock) StringInner() string

type ASTBreak

type ASTBreak struct{}

func NewASTBreak

func NewASTBreak() *ASTBreak

func (*ASTBreak) String

func (b *ASTBreak) String() string

type ASTCase

type ASTCase struct {
	Expression IASTExpression
	Block      *ASTBlock
}

func NewASTCase

func NewASTCase(expression IASTExpression, block *ASTBlock) *ASTCase

func (*ASTCase) String

func (i *ASTCase) String() string

func (*ASTCase) StringInner

func (i *ASTCase) StringInner() string

func (*ASTCase) StringJoined

func (i *ASTCase) StringJoined(cases []*ASTCase) string

type ASTComment

type ASTComment struct {
	MultiLine bool
	Value     string
}

func NewASTComment

func NewASTComment(multiLine bool, value string) *ASTComment

func (*ASTComment) String

func (c *ASTComment) String() string

type ASTContinue

type ASTContinue struct{}

func NewASTContinue

func NewASTContinue() *ASTContinue

func (*ASTContinue) String

func (b *ASTContinue) String() string

type ASTDefault

type ASTDefault struct {
	Block *ASTBlock
}

func NewASTDefault

func NewASTDefault(block *ASTBlock) *ASTDefault

func (*ASTDefault) String

func (i *ASTDefault) String() string

type ASTDoWhile

type ASTDoWhile struct {
	Cond IASTExpression
	Then IASTItem
}

func NewASTDoWhile

func NewASTDoWhile(cond IASTExpression, then IASTItem) *ASTDoWhile

func (*ASTDoWhile) String

func (w *ASTDoWhile) String() string

type ASTEnum

type ASTEnum struct {
	Name       string
	Properties []*ASTEnumProperty
}

func NewASTEnum

func NewASTEnum(name string, properties []*ASTEnumProperty) *ASTEnum

func (*ASTEnum) String

func (s *ASTEnum) String() string

type ASTEnumProperty

type ASTEnumProperty struct {
	Name       string
	Expression IASTExpression
}

func NewASTEnumProperty

func NewASTEnumProperty(name string, expression IASTExpression) *ASTEnumProperty

func (*ASTEnumProperty) String

func (m *ASTEnumProperty) String() string

type ASTExpressionBinary

type ASTExpressionBinary struct {
	Left       IASTExpression
	Operator   string
	Right      IASTExpression
	ReturnType *ASTType
}

func NewASTExpressionBinary

func NewASTExpressionBinary(left IASTExpression, operator string, right IASTExpression, returnType *ASTType) *ASTExpressionBinary

func (*ASTExpressionBinary) GetType

func (e *ASTExpressionBinary) GetType() *ASTType

func (*ASTExpressionBinary) String

func (e *ASTExpressionBinary) String() string

type ASTExpressionCast

type ASTExpressionCast struct {
	Expression IASTExpression
	Type       *ASTType
}

func NewASTExpressionCast

func NewASTExpressionCast(expression IASTExpression, typ *ASTType) *ASTExpressionCast

func (*ASTExpressionCast) GetType

func (e *ASTExpressionCast) GetType() *ASTType

func (*ASTExpressionCast) String

func (e *ASTExpressionCast) String() string

type ASTExpressionConditionalBinary

type ASTExpressionConditionalBinary struct {
	Left     IASTExpression
	Operator string
	Right    IASTExpression
}

func NewASTExpressionConditionalBinary

func NewASTExpressionConditionalBinary(left IASTExpression, operator string, right IASTExpression) *ASTExpressionConditionalBinary

func (*ASTExpressionConditionalBinary) GetType

func (*ASTExpressionConditionalBinary) String

type ASTExpressionEqualityBinary

type ASTExpressionEqualityBinary struct {
	Left     IASTExpression
	Operator string
	Right    IASTExpression
}

func NewASTExpressionEqualityBinary

func NewASTExpressionEqualityBinary(left IASTExpression, operator string, right IASTExpression) *ASTExpressionEqualityBinary

func (*ASTExpressionEqualityBinary) GetType

func (e *ASTExpressionEqualityBinary) GetType() *ASTType

func (*ASTExpressionEqualityBinary) String

func (e *ASTExpressionEqualityBinary) String() string

type ASTExpressionFunctionCall

type ASTExpressionFunctionCall struct {
	Left IASTExpression
	Args []IASTExpression
}

func NewASTExpressionFunctionCall

func NewASTExpressionFunctionCall(left IASTExpression, args []IASTExpression) *ASTExpressionFunctionCall

func (*ASTExpressionFunctionCall) GetType

func (e *ASTExpressionFunctionCall) GetType() *ASTType

func (*ASTExpressionFunctionCall) String

func (e *ASTExpressionFunctionCall) String() string

type ASTExpressionIndex

type ASTExpressionIndex struct {
	Left  IASTExpression
	Index IASTExpression
}

func NewASTExpressionIndex

func NewASTExpressionIndex(left IASTExpression, index IASTExpression) *ASTExpressionIndex

func (*ASTExpressionIndex) GetType

func (e *ASTExpressionIndex) GetType() *ASTType

func (*ASTExpressionIndex) String

func (e *ASTExpressionIndex) String() string

type ASTExpressionLiteral

type ASTExpressionLiteral struct {
	Value string
	Type  *ASTType
}

func NewASTExpressionLiteral

func NewASTExpressionLiteral(value string, typ_ *ASTType) *ASTExpressionLiteral

func (*ASTExpressionLiteral) GetType

func (e *ASTExpressionLiteral) GetType() *ASTType

func (*ASTExpressionLiteral) String

func (e *ASTExpressionLiteral) String() string

type ASTExpressionParenthesized

type ASTExpressionParenthesized struct {
	Expression IASTExpression
}

func NewAstExpressionParenthesized

func NewAstExpressionParenthesized(expression IASTExpression) *ASTExpressionParenthesized

func (*ASTExpressionParenthesized) GetType

func (e *ASTExpressionParenthesized) GetType() *ASTType

func (*ASTExpressionParenthesized) String

func (e *ASTExpressionParenthesized) String() string

type ASTExpressionPointerPropertyAccess

type ASTExpressionPointerPropertyAccess struct {
	Left     IASTExpression
	Property *ASTStructProperty
}

func NewASTExpressionPointerPropertyAccess

func NewASTExpressionPointerPropertyAccess(left IASTExpression, property *ASTStructProperty) *ASTExpressionPointerPropertyAccess

func (*ASTExpressionPointerPropertyAccess) GetType

func (*ASTExpressionPointerPropertyAccess) String

type ASTExpressionPropertyAccess

type ASTExpressionPropertyAccess struct {
	Left     IASTExpression
	Property *ASTStructProperty
}

func NewASTExpressionPropertyAccess

func NewASTExpressionPropertyAccess(left IASTExpression, property *ASTStructProperty) *ASTExpressionPropertyAccess

func (*ASTExpressionPropertyAccess) GetType

func (e *ASTExpressionPropertyAccess) GetType() *ASTType

func (*ASTExpressionPropertyAccess) String

func (e *ASTExpressionPropertyAccess) String() string

type ASTExpressionTernary

type ASTExpressionTernary struct {
	Cond        IASTExpression
	True        IASTExpression
	False       IASTExpression
	IsStatement bool
}

func NewASTExpressionTernary

func NewASTExpressionTernary(cond IASTExpression, true_ IASTExpression, false_ IASTExpression, isStatement bool) *ASTExpressionTernary

func (*ASTExpressionTernary) GetType

func (e *ASTExpressionTernary) GetType() *ASTType

func (*ASTExpressionTernary) String

func (e *ASTExpressionTernary) String() string

type ASTExpressionUnaryPost

type ASTExpressionUnaryPost struct {
	Operand  IASTExpression
	Operator string

	IsStatement bool
}

func NewASTExpressionUnaryPost

func NewASTExpressionUnaryPost(operand IASTExpression, operator string, isStatement bool) *ASTExpressionUnaryPost

func (*ASTExpressionUnaryPost) GetType

func (e *ASTExpressionUnaryPost) GetType() *ASTType

func (*ASTExpressionUnaryPost) String

func (e *ASTExpressionUnaryPost) String() string

type ASTExpressionUnaryPre

type ASTExpressionUnaryPre struct {
	Operator string
	Operand  IASTExpression

	IsStatement bool
}

func NewASTExpressionUnaryPre

func NewASTExpressionUnaryPre(operator string, operand IASTExpression, isStatement bool) *ASTExpressionUnaryPre

func (*ASTExpressionUnaryPre) GetType

func (e *ASTExpressionUnaryPre) GetType() *ASTType

func (*ASTExpressionUnaryPre) String

func (e *ASTExpressionUnaryPre) String() string

type ASTFor

type ASTFor struct {
	Init IASTItem
	Cond IASTExpression
	Post IASTExpression

	Statement IASTItem
}

func NewASTFor

func NewASTFor() *ASTFor

func (*ASTFor) String

func (f *ASTFor) String() string

type ASTFunction

type ASTFunction struct {
	Name       string
	Args       []*ASTFunctionArgument
	IsVariadic bool
	ReturnType *ASTType
	Body       *ASTBlock
}

func NewASTFunction

func NewASTFunction(name string) *ASTFunction

func (*ASTFunction) SetArgs

func (f *ASTFunction) SetArgs(args []*ASTFunctionArgument) *ASTFunction

func (*ASTFunction) SetIsVariadic

func (f *ASTFunction) SetIsVariadic(isVariadic bool) *ASTFunction

func (*ASTFunction) SetReturnType

func (f *ASTFunction) SetReturnType(returnType *ASTType) *ASTFunction

func (*ASTFunction) String

func (f *ASTFunction) String() string

func (*ASTFunction) TypeString

func (f *ASTFunction) TypeString(withName bool) string

type ASTFunctionArgument

type ASTFunctionArgument struct {
	Name string
	Type *ASTType
}

func NewASTFunctionArgument

func NewASTFunctionArgument(name string, typ *ASTType) *ASTFunctionArgument

func (*ASTFunctionArgument) String

func (a *ASTFunctionArgument) String() string

type ASTFunctionReturn

type ASTFunctionReturn struct {
	Expression IASTExpression
	IsInMain   bool
}

func NewASTFunctionReturn

func NewASTFunctionReturn(isInMain bool) *ASTFunctionReturn

func (*ASTFunctionReturn) SetExpression

func (b *ASTFunctionReturn) SetExpression(expression IASTExpression)

func (*ASTFunctionReturn) String

func (b *ASTFunctionReturn) String() string

type ASTGoto

type ASTGoto struct {
	Label string
}

func NewASTGoto

func NewASTGoto(label string) *ASTGoto

func (*ASTGoto) String

func (g *ASTGoto) String() string

type ASTIf

type ASTIf struct {
	Condition IASTExpression
	Then      IASTItem
	Else      IASTItem
}

func NewASTIf

func NewASTIf(condition IASTExpression, then IASTItem) *ASTIf

func (*ASTIf) String

func (i *ASTIf) String() string

type ASTLabel

type ASTLabel struct {
	Name string
}

func NewASTLabel

func NewASTLabel(name string) *ASTLabel

func (*ASTLabel) String

func (l *ASTLabel) String() string

type ASTMultipleStatements

type ASTMultipleStatements struct {
	Statements []IASTItem
}

func NewASTMultipleStatements

func NewASTMultipleStatements(statements []IASTItem) *ASTMultipleStatements

func (*ASTMultipleStatements) String

func (m *ASTMultipleStatements) String() string

type ASTStruct

type ASTStruct struct {
	TypeId string
	Name   string

	IsOpaque   bool
	Properties []*ASTStructProperty
}

func NewAstStructOpaque

func NewAstStructOpaque(name string) *ASTStruct

func (*ASTStruct) GetProperty

func (s *ASTStruct) GetProperty(name string) *ASTStructProperty

func (*ASTStruct) GetPropertyByIndex

func (s *ASTStruct) GetPropertyByIndex(index int) *ASTStructProperty

func (*ASTStruct) IsSameTo

func (s *ASTStruct) IsSameTo(other *ASTStruct) bool

func (*ASTStruct) SetProperties

func (s *ASTStruct) SetProperties(properties []*ASTStructProperty) *ASTStruct

func (*ASTStruct) String

func (s *ASTStruct) String() string

func (*ASTStruct) TypeString

func (s *ASTStruct) TypeString() string

type ASTStructProperty

type ASTStructProperty struct {
	Name string
	Type *ASTType
}

func NewASTStructProperty

func NewASTStructProperty(name string, typ *ASTType) *ASTStructProperty

func (*ASTStructProperty) GetTranslatedName

func (p *ASTStructProperty) GetTranslatedName() string

func (*ASTStructProperty) String

func (m *ASTStructProperty) String() string

type ASTSwitch

type ASTSwitch struct {
	Expression  IASTExpression
	Cases       []*ASTCase
	DefaultCase *ASTDefault
}

func NewASTSwitch

func NewASTSwitch(expression IASTExpression) *ASTSwitch

func (*ASTSwitch) AddCase

func (s *ASTSwitch) AddCase(case_ *ASTCase)

func (*ASTSwitch) SetDefaultCase

func (s *ASTSwitch) SetDefaultCase(defaultCase *ASTDefault)

func (*ASTSwitch) String

func (i *ASTSwitch) String() string

type ASTType

type ASTType struct {
	Kind ASTTypeKind
	Name string

	IsSigned bool

	ArrayType    *ASTType
	ArraySize    IASTExpression
	PointerType  *ASTType
	FunctionType *ASTFunction
	StructType   *ASTStruct
}

func NewASTType

func NewASTType(kind ASTTypeKind, name string) *ASTType

func (*ASTType) IsArray

func (t *ASTType) IsArray() bool

func (*ASTType) IsConvertibleTo

func (t *ASTType) IsConvertibleTo(targetType *ASTType) bool

func (*ASTType) IsFloat

func (t *ASTType) IsFloat() bool

func (*ASTType) IsFunction

func (t *ASTType) IsFunction() bool

func (*ASTType) IsInteger

func (t *ASTType) IsInteger() bool

func (*ASTType) IsPointer

func (t *ASTType) IsPointer() bool

func (*ASTType) IsSameTo

func (t *ASTType) IsSameTo(other *ASTType) bool

func (*ASTType) IsStruct

func (t *ASTType) IsStruct() bool

func (*ASTType) IsVoid

func (t *ASTType) IsVoid() bool

func (*ASTType) SetArraySize

func (t *ASTType) SetArraySize(expression IASTExpression) *ASTType

func (*ASTType) SetArrayType

func (t *ASTType) SetArrayType(arrayType *ASTType) *ASTType

func (*ASTType) SetFunctionType

func (t *ASTType) SetFunctionType(functionType *ASTFunction) *ASTType

func (*ASTType) SetIsSigned

func (t *ASTType) SetIsSigned(isSigned bool)

func (*ASTType) SetPointerType

func (t *ASTType) SetPointerType(pointerType *ASTType) *ASTType

func (*ASTType) SetStructType

func (t *ASTType) SetStructType(structType *ASTStruct) *ASTType

func (*ASTType) String

func (t *ASTType) String() string

type ASTTypeConversion

type ASTTypeConversion struct {
	Expression IASTExpression
	TargetType *ASTType
}

func NewAstTypeConversion

func NewAstTypeConversion(expression IASTExpression, targetType *ASTType) (*ASTTypeConversion, error)

func (*ASTTypeConversion) GetType

func (t *ASTTypeConversion) GetType() *ASTType

func (*ASTTypeConversion) String

func (t *ASTTypeConversion) String() string

type ASTTypeKind

type ASTTypeKind int64
const (
	ASTTypeKindAny ASTTypeKind = iota

	ASTTypeKindVoid
	ASTTypeKindInt
	ASTTypeKindInt16
	ASTTypeKindInt64
	ASTTypeKindChar
	ASTTypeKindByte
	ASTTypeKindFloat32
	ASTTypeKindFloat64

	ASTTypeKindBool

	ASTTypeKindArray
	ASTTypeKindPointer

	ASTTypeKindStruct

	ASTTypeKindFunction
)

type ASTTypedef

type ASTTypedef struct {
	Name string
	Type *ASTType
}

func NewASTTypedef

func NewASTTypedef(name string, typ *ASTType) *ASTTypedef

func (*ASTTypedef) String

func (t *ASTTypedef) String() string

type ASTVariableDeclaration

type ASTVariableDeclaration struct {
	IsStatement          bool
	ForceFullDeclaration bool
	Items                []*ASTVariableDeclarationItem
}

func NewASTVariableDeclaration

func NewASTVariableDeclaration(isStatement bool) *ASTVariableDeclaration

func (*ASTVariableDeclaration) SetForceFullDeclaration

func (v *ASTVariableDeclaration) SetForceFullDeclaration(forceFullDeclaration bool) *ASTVariableDeclaration

func (*ASTVariableDeclaration) String

func (v *ASTVariableDeclaration) String() string

func (*ASTVariableDeclaration) StringStatement

func (v *ASTVariableDeclaration) StringStatement() string

type ASTVariableDeclarationItem

type ASTVariableDeclarationItem struct {
	Name       string
	Type       *ASTType
	Expression IASTExpression
}

func NewASTVariableDeclarationItem

func NewASTVariableDeclarationItem(name string, typ *ASTType, expression IASTExpression) *ASTVariableDeclarationItem

type ASTWhile

type ASTWhile struct {
	Cond IASTExpression
	Then IASTItem
}

func NewASTWhile

func NewASTWhile(cond IASTExpression, then IASTItem) *ASTWhile

func (*ASTWhile) String

func (w *ASTWhile) String() string

type AstArrayInitialization

type AstArrayInitialization struct {
	Type   *ASTType
	Fields []IASTExpression
}

func NewAstArrayInitialization

func NewAstArrayInitialization(typ *ASTType, fields []IASTExpression) *AstArrayInitialization

func (*AstArrayInitialization) GetType

func (e *AstArrayInitialization) GetType() *ASTType

func (*AstArrayInitialization) String

func (e *AstArrayInitialization) String() string

type AstStructInitialization

type AstStructInitialization struct {
	Struct *ASTType
	Fields []IASTExpression
}

func NewAstStructInitialization

func NewAstStructInitialization(typ *ASTType, fields []IASTExpression) *AstStructInitialization

func (*AstStructInitialization) GetType

func (e *AstStructInitialization) GetType() *ASTType

func (*AstStructInitialization) String

func (e *AstStructInitialization) String() string

type AstStructNamedInitialization

type AstStructNamedInitialization struct {
	Struct      *ASTType
	Names       []string
	Expressions []IASTExpression
}

func NewAstStructNamedInitialization

func NewAstStructNamedInitialization(typ *ASTType, names []string, expressions []IASTExpression) *AstStructNamedInitialization

func (*AstStructNamedInitialization) GetType

func (s *AstStructNamedInitialization) GetType() *ASTType

func (*AstStructNamedInitialization) String

type IASTExpression

type IASTExpression interface {
	IASTItem

	GetType() *ASTType
}

func EnsureConditionalValidity

func EnsureConditionalValidity(expression IASTExpression) IASTExpression

type IASTItem

type IASTItem interface {
	String() string
}

Jump to

Keyboard shortcuts

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