Skip to content

Light-weight expression manipulation tools

License

Notifications You must be signed in to change notification settings

zeta1999/ExprTools.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExprTools

Stable Dev Build Status Coverage

ExprTools provides tooling for working with Julia expressions during metaprogramming. This package aims to provide light-weight performant tooling without requiring additional package dependencies.

Alternatively see the MacroTools package for a more powerful set of tools.

Currently, this package provides the splitdef and combinedef functions which are useful for inspecting and manipulating function definition expressions.

e.g.

julia> using ExprTools

julia> ex = :(
           function Base.f(x::T, y::T) where T
               x + y
           end
       )
:(function Base.f(x::T, y::T) where T
      #= none:3 =#
      x + y
  end)

julia> def = splitdef(ex)
Dict{Symbol,Any} with 5 entries:
  :args        => Any[:(x::T), :(y::T)]
  :body        => quote
  :name        => :(Base.f)
  :head        => :function
  :whereparams => Any[:T]

julia> def[:name] = :g;

julia> def[:head] = :(=);

julia> def[:body] = :(x * y);

julia> combinedef(def)
:((g(x::T, y::T) where T) = x * y)

About

Light-weight expression manipulation tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%