ast

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessSpecifier

type AccessSpecifier uint
const (
	Invalid AccessSpecifier = iota
	Public
	Protected
	Private
)

type ArrayType

type ArrayType struct {
	Elt Expr
	Len Expr // optional
}

Elt[Len] Elt[]

type BasicLit

type BasicLit struct {
	Kind  BasicLitKind
	Value string
}

type BasicLitKind

type BasicLitKind uint
const (
	IntLit BasicLitKind = iota
	FloatLit
	CharLit
	StringLit
)

type BlockPointerType added in v0.5.1

type BlockPointerType struct {
	X *FuncType
}

Ret (^)(Params)

type BuiltinType

type BuiltinType struct {
	Kind  TypeKind
	Flags TypeFlag
}

[signed/unsigned/short/long/long long/double] [int]/char/float/complex/bool

type Comment

type Comment struct {
	Text string // comment text (excluding '\n' for //-style comments)
}

type CommentGroup

type CommentGroup struct {
	List []*Comment // len(List) > 0
}

type Decl

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

Decl is a declaration node.

type EnumItem

type EnumItem struct {
	Name  *Ident
	Value Expr // optional
}

type EnumType

type EnumType struct {
	Items []*EnumItem
}

type EnumTypeDecl

type EnumTypeDecl struct {
	Object
	Type *EnumType
}

enum Name { Item1, Item2, ... };

type Expr

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

Expr is an expression node.

type Field

type Field struct {
	Doc      *CommentGroup   // associated documentation; or nil
	Type     Expr            // field/method/parameter type; or nil
	Names    []*Ident        // field/method/(type) parameter names; or nil
	Comment  *CommentGroup   // line comments; or nil
	Access   AccessSpecifier // field access(Record Type); Struct Field default is Public,Class Field default is Private
	IsStatic bool            // static field
}

type FieldList

type FieldList struct {
	List []*Field // field list; or nil
}

type File

type File struct {
	Decls    []Decl     `json:"decls"`
	Includes []*Include `json:"includes,omitempty"`
	Macros   []*Macro   `json:"macros,omitempty"`
}

type FuncDecl

type FuncDecl struct {
	Object
	MangledName string // C: same as Name, C++: mangled
	Type        *FuncType
	IsInline    bool
	IsStatic    bool

	// Class method specific fields
	IsConst       bool // const member function
	IsExplicit    bool // explicit constructor
	IsConstructor bool
	IsDestructor  bool
	IsVirtual     bool
	IsOverride    bool
}

Ret Name(Params);

type FuncType

type FuncType struct {
	Params *FieldList
	Ret    Expr
}

Ret (*)(Params)

type Ident

type Ident struct {
	Name string
}

Name

type Include

type Include struct {
	Path string `json:"path"`
}

type InstantiationType

type InstantiationType struct {
	Template Expr
	Args     *FieldList
}

Template<Arg1, Arg2, ...>

type Location

type Location struct {
	File string
}

type LvalueRefType

type LvalueRefType struct {
	X Expr
}

X&

type Macro

type Macro struct {
	Loc    *Location
	Name   string
	Tokens []*Token // Tokens[0].Lit is the macro name
}

type Node

type Node any

Node is the interface for an AST nodes.

type Object added in v0.5.0

type Object struct {
	Doc    *CommentGroup // associated documentation; or nil
	Loc    *Location
	Name   *Ident
	Parent Expr // namespace or class
}

func ObjectOf added in v0.5.0

func ObjectOf(decl Decl) *Object

ObjectOf returns the object of the declaration.

type PPD

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

PPD is a preprocessing directive node.

type ParenExpr

type ParenExpr struct {
	X Expr
}

(X)

type PointerType

type PointerType struct {
	X Expr
}

X*

type RecordType

type RecordType struct {
	Tag     Tag
	Fields  *FieldList
	Methods []*FuncDecl
}

type RvalueRefType

type RvalueRefType struct {
	X Expr
}

X&&

type ScopingExpr

type ScopingExpr struct {
	Parent Expr
	X      *Ident
}

Parent::X

type Stmt

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

Stmt is a statement node.

type Tag

type Tag int
const (
	Struct Tag = iota
	Union
	Enum
	Class
)

type TagExpr

type TagExpr struct {
	Tag  Tag
	Name Expr // ScopingExpr, Ident
}

struct/union/enum/class (A::B::)Name

type Token

type Token struct {
	Token token.Token
	Lit   string
}

type TypeDecl

type TypeDecl struct {
	Object
	Type *RecordType
}

struct/union/class Name { Field1, Field2, ... };

type TypeFlag

type TypeFlag uint
const (
	Signed TypeFlag = 1 << iota
	Unsigned
	Long
	LongLong
	Double
	Short
)

type TypeKind

type TypeKind uint
const (
	Void TypeKind = iota
	Bool
	Char
	Char16
	Char32
	WChar
	Int
	Int128
	Float
	Float16
	Float128
	Complex
)

type TypedefDecl

type TypedefDecl struct {
	Object
	Type Expr
}

typedef Type Name;

type Variadic

type Variadic struct {
}

type a, ...

Jump to

Keyboard shortcuts

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