parser

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbgParse   dbgFlags = 1 << iota
	DbgFlagAll          = DbgParse
)

Variables

This section is empty.

Functions

func Do

func Do(config *ConverterConfig) (*ast.File, error)

func IsExplicitSigned

func IsExplicitSigned(t clang.Type) bool

func IsExplicitUnsigned

func IsExplicitUnsigned(t clang.Type) bool

func PostOrderVisitChildren added in v0.7.3

func PostOrderVisitChildren(cursor clang.Cursor, collect func(c, p clang.Cursor) bool) []clang.Cursor

func SetDebug

func SetDebug(dbgFlags dbgFlags)

func XMarshalASTDecl added in v0.5.1

func XMarshalASTDecl(decl ast.Decl) map[string]any

func XMarshalASTExpr added in v0.5.1

func XMarshalASTExpr(t ast.Expr) map[string]any

func XMarshalASTFile added in v0.5.1

func XMarshalASTFile(file *ast.File) map[string]any

func XMarshalDeclList added in v0.5.1

func XMarshalDeclList(list []ast.Decl) []map[string]any

func XMarshalFieldList added in v0.5.1

func XMarshalFieldList(list []*ast.Field) []map[string]any

func XMarshalIdentList added in v0.5.1

func XMarshalIdentList(list []*ast.Ident) []map[string]any

func XMarshalIncludeList added in v0.5.1

func XMarshalIncludeList(list []*ast.Include) []map[string]any

func XMarshalLocation added in v0.5.1

func XMarshalLocation(loc *ast.Location) map[string]any

func XMarshalMacroList added in v0.5.1

func XMarshalMacroList(list []*ast.Macro) []map[string]any

func XMarshalObject added in v0.5.1

func XMarshalObject(decl ast.Object, root map[string]any)

func XMarshalToken added in v0.5.1

func XMarshalToken(tok *ast.Token) map[string]any

func XMarshalTokenList added in v0.5.1

func XMarshalTokenList(list []*ast.Token) []map[string]any

Types

type Converter

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

func NewConverter

func NewConverter(config *ConverterConfig) (*Converter, error)

func (*Converter) BuildScopingExpr

func (ct *Converter) BuildScopingExpr(cursor clang.Cursor) ast.Expr

Constructs a complete scoping expression by traversing the semantic parents, starting from the given clang.Cursor For anonymous decl of typedef references, use their anonymous name

func (*Converter) Convert

func (ct *Converter) Convert() (*ast.File, error)

for flatten ast,keep type order input is clang -E 's result

func (*Converter) CreateObject

func (ct *Converter) CreateObject(cursor clang.Cursor, name *ast.Ident) ast.Object

func (*Converter) Dispose

func (ct *Converter) Dispose()

func (*Converter) GetTokens

func (ct *Converter) GetTokens(cursor clang.Cursor) []*ast.Token

func (*Converter) InFile

func (ct *Converter) InFile(cursor clang.Cursor) bool

func (*Converter) ParseComment

func (ct *Converter) ParseComment(rawComment string) *ast.CommentGroup

func (*Converter) ParseCommentGroup

func (ct *Converter) ParseCommentGroup(cursor clang.Cursor) (comentGroup *ast.CommentGroup, isDoc bool)

extracts and parses comments associated with a given Clang cursor, distinguishing between documentation comments and line comments.

The function determines whether a comment is a documentation comment or a line comment by comparing the range of the comment node with the range of the declaration node in the AST.

Note: In cases where both documentation comments and line comments conceptually exist, only the line comment will be preserved.

func (*Converter) ProcessBuiltinType

func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType

func (*Converter) ProcessClassDecl

func (ct *Converter) ProcessClassDecl(cursor clang.Cursor) *ast.TypeDecl

func (*Converter) ProcessElaboratedType

func (ct *Converter) ProcessElaboratedType(t clang.Type) ast.Expr

process ElaboratedType Reference

1. Named elaborated type references: - Examples: struct MyStruct, union MyUnion, class MyClass, enum MyEnum - Handling: Constructed as TagExpr or ScopingExpr references

2. Anonymous elaborated type references: - Examples: struct { int x; int y; }, union { int a; float b; } - Handling: Retrieve their corresponding concrete types

func (*Converter) ProcessEnumDecl

func (ct *Converter) ProcessEnumDecl(cursor clang.Cursor) *ast.EnumTypeDecl

func (*Converter) ProcessEnumType

func (ct *Converter) ProcessEnumType(cursor clang.Cursor) *ast.EnumType

func (*Converter) ProcessFieldList

func (ct *Converter) ProcessFieldList(cursor clang.Cursor) *ast.FieldList

For Record Type(struct,union ...)'s FieldList

func (*Converter) ProcessFuncDecl

func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl

converts functions, methods, constructors, destructors (including out-of-class decl) to ast.FuncDecl nodes.

func (*Converter) ProcessFunctionType

func (ct *Converter) ProcessFunctionType(t clang.Type) *ast.FuncType

For function types, we can only obtain the parameter types, but not the parameter names. This is because we cannot reverse-lookup the corresponding declaration node from a function type. Note: For function declarations, parameter names are collected in the ProcessFuncDecl method.

func (*Converter) ProcessInclude

func (ct *Converter) ProcessInclude(cursor clang.Cursor) (*ast.Include, error)

func (*Converter) ProcessMacro

func (ct *Converter) ProcessMacro(cursor clang.Cursor) *ast.Macro

current only collect macro which defined in file

func (*Converter) ProcessMethodAttributes

func (ct *Converter) ProcessMethodAttributes(cursor clang.Cursor, fn *ast.FuncDecl)

get Methods Attributes

func (*Converter) ProcessMethods

func (ct *Converter) ProcessMethods(cursor clang.Cursor) []*ast.FuncDecl

Note:Public Method is considered

func (*Converter) ProcessRecordDecl

func (ct *Converter) ProcessRecordDecl(cursor clang.Cursor) []ast.Decl

func (*Converter) ProcessRecordType

func (ct *Converter) ProcessRecordType(cursor clang.Cursor) *ast.RecordType

func (*Converter) ProcessStructDecl

func (ct *Converter) ProcessStructDecl(cursor clang.Cursor) []ast.Decl

func (*Converter) ProcessType

func (ct *Converter) ProcessType(t clang.Type) ast.Expr

func (*Converter) ProcessTypeDefDecl

func (ct *Converter) ProcessTypeDefDecl(cursor clang.Cursor) *ast.TypedefDecl

func (*Converter) ProcessTypeDefType

func (ct *Converter) ProcessTypeDefType(t clang.Type) ast.Expr

func (*Converter) ProcessUnderlyingType

func (ct *Converter) ProcessUnderlyingType(cursor clang.Cursor) ast.Expr

func (*Converter) ProcessUnionDecl

func (ct *Converter) ProcessUnionDecl(cursor clang.Cursor) []ast.Decl

type ConverterConfig

type ConverterConfig struct {
	File  string
	Args  []string
	IsCpp bool
}

Jump to

Keyboard shortcuts

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