File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ const OP_NAMES = Dict(
190190 " safe_pow" => " ^" ,
191191)
192192
193+ get_op_name (op:: String ) = op
193194@generated function get_op_name (op:: F ) where {F}
194195 try
195196 # Bit faster to just cache the name of the operator:
@@ -266,7 +267,7 @@ Convert an equation to a string.
266267"""
267268function string_tree (
268269 tree:: Node{T} ,
269- operators:: AbstractOperatorEnum ;
270+ operators:: Union{ AbstractOperatorEnum,Nothing} = nothing ;
270271 bracketed:: Bool = false ,
271272 f_variable:: F1 = string_variable,
272273 f_constant:: F2 = string_constant,
@@ -284,7 +285,11 @@ function string_tree(
284285 elseif tree. degree == 1
285286 return string_op (
286287 Val (1 ),
287- operators. unaops[tree. op],
288+ if operators === nothing
289+ " unary_operator[" * string (tree. op) * " ]"
290+ else
291+ operators. unaops[tree. op]
292+ end ,
288293 tree,
289294 operators;
290295 bracketed,
@@ -295,7 +300,11 @@ function string_tree(
295300 else
296301 return string_op (
297302 Val (2 ),
298- operators. binops[tree. op],
303+ if operators === nothing
304+ " binary_operator[" * string (tree. op) * " ]"
305+ else
306+ operators. binops[tree. op]
307+ end ,
299308 tree,
300309 operators;
301310 bracketed,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ const ALREADY_DEFINED_BINARY_OPERATORS = (;
3131function Base. show (io:: IO , tree:: Node )
3232 latest_operators_type = LATEST_OPERATORS_TYPE. x
3333 if latest_operators_type == IsNothing
34- return print (io, string (tree))
34+ return print (io, string_tree (tree))
3535 elseif latest_operators_type == IsOperatorEnum
3636 latest_operators = LATEST_OPERATORS. x:: OperatorEnum
3737 return print (io, string_tree (tree, latest_operators))
You can’t perform that action at this time.
0 commit comments