regexpcode

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Null              = []byte("")
	LineComment       = regexp.MustCompile(`//.*`)
	MultiComment      = regexp.MustCompile(`/\*(\n|.)*?\*/`)
	EmptyLineCompile  = regexp.MustCompile(`(?m)^\s*$[\r\n]*|[\r\n]+\s+\z`)
	AnnotationCompile = regexp.MustCompile("`(\\w+:\"\\w+\"\\s*)`")
	PackageCmp        = regexp.MustCompile(`(?m)^package (\w+)`)
	ImportBlockCmp    = regexp.MustCompile(`(?m)^import (\((\s+(\w+ )?("([\w/.]+)"))+\s*\)|"([\w/.]+)")`)
	ImportBlockSubCmp = regexp.MustCompile(`"([\w/.]+)"`)
	VarLineCmp        = regexp.MustCompile(`(?m)^var (\w+(?: (?:` + paramType + `)?(?: = .+?)?){?\s+$`)
	VarBlockCmp       = regexp.MustCompile(`(?m)^var \((\s+\w+([\t ]+(` + paramType + `)?([\t ]+=[\t ]+.+)?)+\s*\)`)
	VarBlockLineCmp   = regexp.MustCompile(`[\t ](\w+(?:[\t ]+(?:` + paramType + `)?(?:[\t ]+=[\t ]+[^\n\r]+)?)`)
	ConstLineCmp      = regexp.MustCompile(`(?m)^const (\w+(?: (?:` + paramType + `)?(?: = .+?)?)\s+$`)
	ConstBlockCmp     = regexp.MustCompile(`(?m)^const \((\s+\w+([\t ]+(` + paramType + `)?([\t ]+=[\t ]+.+?)?)+\s*\)`)
	ConstBlockLineCmp = VarBlockLineCmp
	TypeCmp           = regexp.MustCompile(`(?m)^type (\w+) ((?:` + paramType + `)\s+$`)
	TypeSuperCmp      = regexp.MustCompile(`(?m)^[\t ]+(\w+)\s*$`)
	StructCmp         = regexp.MustCompile(`(?m)^(?:type |[\t ]+)(\w+) struct\s?\{((?:\s+\w+(?:, \w+)*?(?:[\t ]+(?:` + paramType + `)?)+)\s*}`)
	StructFieldCmp    = regexp.MustCompile(`(?m)^[\t ]+(\w+(?:, \w+)*)[\t ]+((?:(?:` + paramType + `)+)\s*$`)
	StructFuncCmp     = regexp.MustCompile(`(?m)^func \((\*?\w+? ?\*?\w+?)\) (\w+)(\((?:\w+(?:, \w+)*? (?:chan |[\w\[\].*]|\{})+(?:, )?)*\)[\t ]*\(?(?:\w*?(?:, \w+)*? ?(?:chan |[\w\[\].*]|\{})*(?:, )?)*\)?)\s*?\{`)
	InterfaceCmp      = regexp.MustCompile(`(?m)^(?:type |[\t ]+)(\w+) interface\s?\{((?:\s*\w*(?:` + funcParamList + `)?)*)\s*}`)
	InterfaceLineCmp  = regexp.MustCompile(`[\t ]+(\w+)(\(.*?\))(.*)?`)
	InterfaceDepsCmp  = regexp.MustCompile(`\w+(?:, \w+)*? ((?:` + paramType + `)(?:, )?`)
	FuncGlobalCmp     = regexp.MustCompile(`(?m)^func (\w+)(` + funcParamList + `)\s*?\{`)
)

Functions

func BindingStructs

func BindingStructs(structs []*Struct, mFuncsPointer *[]*MFunc)

BindingStructs 检索并绑定成员函数,每次匹配都会移除@mFuncsPointer列表中的元素

func ClearAnnotation

func ClearAnnotation(bs []byte) []byte

func ClearEmptyLine

func ClearEmptyLine(bs []byte) []byte

func ClearLineComment

func ClearLineComment(bs []byte) []byte

func ClearMultiComment

func ClearMultiComment(bs []byte) []byte

func ClenCode

func ClenCode(bs []byte) []byte

func FindAllConsts

func FindAllConsts(content []byte) (consts []string)

func FindAllImports

func FindAllImports(content []byte) (imports []string)

func FindAllVars

func FindAllVars(content []byte) (vars []string)

func FindPackage

func FindPackage(content []byte) string

Types

type GFunc

type GFunc struct {
	Name   string
	Header string
	Types  []string
}

func FindAllGFuncs

func FindAllGFuncs(content []byte) (v []*GFunc)

type Interface

type Interface struct {
	Name   string
	Supers []string
	Funcs  []*GFunc
}

func FindAllInterfaces

func FindAllInterfaces(content []byte) (interfaces []*Interface)

type MFunc

type MFunc struct {
	*GFunc
	Master string
}

func FindAllMFuncs

func FindAllMFuncs(content []byte) (mFuncs []*MFunc)

type Struct

type Struct struct {
	Name    string
	Package string
	Supers  []string
	Fields  []string
	Funcs   []*MFunc
}

func FindAllStructs

func FindAllStructs(content []byte, pkg string) (structs []*Struct)

Jump to

Keyboard shortcuts

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