CliMA / Impero.jl

A symbolic language for equation specification
Apache License 2.0
15 stars 1 forks source link

To Expression function #5

Closed sandreza closed 4 years ago

sandreza commented 4 years ago

Being able to convert back and forth between julia Expr objects and the custom objects in Impero could allow for a number of useful features. This can be currently achieved by going through SymbolicUtils and using a to_expr function such as which requires the object to be a SymbolicUtils term object:

to_expr(t::Term) = Expr(:call, operation(t), to_expr.(arguments(t))...)
to_expr(x) = x

but it would be nice to do this directly. This would allow for the plotting of the syntax trees implied by Impero structs via GraphRecipes as in

using GraphRecipes
using Plots
theme(:default)
default(size=(400, 400))
p1 = plot(expr_rhs, shape = :circle, fontsize=10, shorten=0.01, axis_buffer=0.15)

where expr_rhs is an expression object.

sandreza commented 4 years ago

This has been partially accomplished through #11