macro

package
v0.0.0-...-be1beb9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MacroSymbol     = "_μ"
	Seq_μTypeSymbol = "seq_μ"
	NewSeq_μSymbol  = "NewSeq_μ"
	Try_μSymbol     = "Try_μ"
	Log_μSymbol     = "Log_μ"
	MacroPkgPath    = "github.com/mmirolim/gpp/macro"
	MacroPkgName    = "macro"
)
View Source
const LogFuncStubName = "__nooplog_"

LogFuncStubName used as stub to mute unmatched log lines

Variables

View Source
var ApplyState = struct {
	MacroLibName string
	RemoveLib    bool
	File         *ast.File
	Fset         *token.FileSet
	Pkg          *packages.Package
	SrcDir       string
	LogRe        *regexp.Regexp
	IsOuterMacro bool
}{}

TODO move to context?

View Source
var MacroDecl = map[string]*ast.FuncDecl{}

define custom macro expand functions TODO make settable, prefixed by modulename?

Functions

func AllMacroDecl

func AllMacroDecl(f *ast.File, allMacroDecl map[string]*ast.FuncDecl)

AllMacroDecl collects func decl of macros

func CreateNoOpFuncDecl

func CreateNoOpFuncDecl(name string) *ast.FuncDecl

func Filter_μ

func Filter_μ(in, out, fn interface{})

Filter_μ (in, out) pointers to slices and fn func(_T [, int]) bool

func FormatNode

func FormatNode(node ast.Node) (string, error)

FormatNode format to text

func IdentsFromCallExpr

func IdentsFromCallExpr(expr *ast.CallExpr, idents *[]*ast.Ident, callArgs *[][]ast.Expr)

IdentsFromCallExpr

func IsMacroDecl

func IsMacroDecl(decl *ast.FuncDecl) bool

func Log_μ

func Log_μ(args ...interface{})

func MacroGeneralExpand

func MacroGeneralExpand(
	cur *astutil.Cursor,
	parentStmt ast.Stmt,
	idents []*ast.Ident,
	callArgs [][]ast.Expr,
	pre, post astutil.ApplyFunc) bool

MacroGeneralExpand default expander TODO describe rules

func MacroLogExpand

func MacroLogExpand(
	cur *astutil.Cursor,
	parentStmt ast.Stmt,
	idents []*ast.Ident,
	callArgs [][]ast.Expr,
	pre, post astutil.ApplyFunc) bool

MacroLogExpand transformer for Log_μ

func MacroNewSeq

func MacroNewSeq(
	cur *astutil.Cursor,
	parentStmt ast.Stmt,
	idents []*ast.Ident,
	callArgs [][]ast.Expr,
	pre, post astutil.ApplyFunc) bool

MacroNewSeq macro expander for sequence M/F/R

func MacroTryExpand

func MacroTryExpand(
	cur *astutil.Cursor,
	parentStmt ast.Stmt,
	idents []*ast.Ident,
	callArgs [][]ast.Expr,
	pre, post astutil.ApplyFunc) bool

MacroTryExpand try macro expander

func MapKeys_μ

func MapKeys_μ(keys, m interface{})

MapKeys_μ returns map keys

func MapToSlice_μ

func MapToSlice_μ(sl, m, f interface{})

MapToSlice_μ apply f to elements of m to generate sl

func MapVals_μ

func MapVals_μ(vals, m interface{})

MapVals_μ returns map values

func Map_μ

func Map_μ(in, out, fn interface{})

Map_μ (in, out) pointers to slices and fn func(_T [, int]) _G

func NewSeq_μ

func NewSeq_μ(src interface{}) *seq_μ

NewSeq_μ constructs new sequence and scope src must be slice and passed by value does not modify slice

func Post

func Post(cur *astutil.Cursor) bool

Post ApplyFunc for ast processing

func Pre

func Pre(cur *astutil.Cursor) bool

Pre ApplyFunc for ast processing

func PrintMapKeys_μ

func PrintMapKeys_μ(keys, m interface{})

PrintMapKeys_μ prints provided keys and values

func PrintMap_μ

func PrintMap_μ(m interface{})

PrintMap_μ prints map

func PrintMapf_μ

func PrintMapf_μ(f string, m interface{})

PrintMapf_μ prints map in f format

func PrintSlice_μ

func PrintSlice_μ(sl interface{})

PrintSlice_μ --

func Reduce_μ

func Reduce_μ(in, out, fn interface{})

Reduce_μ in pointer/value to slice, out pointer *_G and fn func(_G, _T [, int]) _G

func Try_μ

func Try_μ(fn interface{}) error

Types

type MacroExpander

type MacroExpander func(cur *astutil.Cursor,
	parentStmt ast.Stmt,
	idents []*ast.Ident,
	callArgs [][]ast.Expr,
	pre, post astutil.ApplyFunc,
) bool

MacroExpander expander function type

Jump to

Keyboard shortcuts

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