parser

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 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 MarshalASTDecl

func MarshalASTDecl(decl ast.Decl) *cjson.JSON

func MarshalASTExpr

func MarshalASTExpr(t ast.Expr) *cjson.JSON

func MarshalASTFile

func MarshalASTFile(file *ast.File) *cjson.JSON

func MarshalDeclList

func MarshalDeclList(list []ast.Decl) *cjson.JSON

func MarshalFieldList

func MarshalFieldList(list []*ast.Field) *cjson.JSON

func MarshalIdentList

func MarshalIdentList(list []*ast.Ident) *cjson.JSON

func MarshalIncludeList

func MarshalIncludeList(list []*ast.Include) *cjson.JSON

func MarshalLocation

func MarshalLocation(loc *ast.Location) *cjson.JSON

func MarshalMacroList

func MarshalMacroList(list []*ast.Macro) *cjson.JSON

func MarshalObject

func MarshalObject(decl ast.Object, root *cjson.JSON)

func MarshalToken

func MarshalToken(tok *ast.Token) *cjson.JSON

func MarshalTokenList

func MarshalTokenList(list []*ast.Token) *cjson.JSON

func SetDebug

func SetDebug(dbgFlags dbgFlags)

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.TypeDecl

func (*Converter) ProcessRecordType

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

func (*Converter) ProcessStructDecl

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

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.TypeDecl

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