Documentation ¶
Index ¶
- Constants
- Variables
- func AllMacroDecl(f *ast.File, allMacroDecl map[string]*ast.FuncDecl)
- func CreateNoOpFuncDecl(name string) *ast.FuncDecl
- func Filter_μ(in, out, fn interface{})
- func FormatNode(node ast.Node) (string, error)
- func IdentsFromCallExpr(expr *ast.CallExpr, idents *[]*ast.Ident, callArgs *[][]ast.Expr)
- func IsMacroDecl(decl *ast.FuncDecl) bool
- func Log_μ(args ...interface{})
- func MacroGeneralExpand(cur *astutil.Cursor, parentStmt ast.Stmt, idents []*ast.Ident, ...) bool
- func MacroLogExpand(cur *astutil.Cursor, parentStmt ast.Stmt, idents []*ast.Ident, ...) bool
- func MacroNewSeq(cur *astutil.Cursor, parentStmt ast.Stmt, idents []*ast.Ident, ...) bool
- func MacroTryExpand(cur *astutil.Cursor, parentStmt ast.Stmt, idents []*ast.Ident, ...) bool
- func MapKeys_μ(keys, m interface{})
- func MapToSlice_μ(sl, m, f interface{})
- func MapVals_μ(vals, m interface{})
- func Map_μ(in, out, fn interface{})
- func NewSeq_μ(src interface{}) *seq_μ
- func Post(cur *astutil.Cursor) bool
- func Pre(cur *astutil.Cursor) bool
- func PrintMapKeys_μ(keys, m interface{})
- func PrintMap_μ(m interface{})
- func PrintMapf_μ(f string, m interface{})
- func PrintSlice_μ(sl interface{})
- func Reduce_μ(in, out, fn interface{})
- func Try_μ(fn interface{}) error
- type MacroExpander
Constants ¶
const ( MacroSymbol = "_μ" Seq_μTypeSymbol = "seq_μ" NewSeq_μSymbol = "NewSeq_μ" Try_μSymbol = "Try_μ" Log_μSymbol = "Log_μ" MacroPkgPath = "github.com/mmirolim/gpp/macro" MacroPkgName = "macro" )
const LogFuncStubName = "__nooplog_"
LogFuncStubName used as stub to mute unmatched log lines
Variables ¶
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?
var MacroDecl = map[string]*ast.FuncDecl{}
var MacroExpanders = map[string]MacroExpander{ Seq_μTypeSymbol: MacroNewSeq, Try_μSymbol: MacroTryExpand, Log_μSymbol: MacroLogExpand, }
define custom macro expand functions TODO make settable, prefixed by modulename?
Functions ¶
func AllMacroDecl ¶
AllMacroDecl collects func decl of macros
func CreateNoOpFuncDecl ¶
func Filter_μ ¶
func Filter_μ(in, out, fn interface{})
Filter_μ (in, out) pointers to slices and fn func(_T [, int]) bool
func IdentsFromCallExpr ¶
IdentsFromCallExpr
func IsMacroDecl ¶
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 MapToSlice_μ ¶
func MapToSlice_μ(sl, m, f interface{})
MapToSlice_μ apply f to elements of m to generate sl
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 PrintMapKeys_μ ¶
func PrintMapKeys_μ(keys, m interface{})
PrintMapKeys_μ prints provided keys and values