From 3eddd5ce8882e8514bd1cc4e2b6fec7ff5b1c5f6 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Wed, 15 Mar 2017 12:52:55 +0100
Subject: [PATCH] preprocessor: split equation output into lhs and rhs. #1387

---
 ModelTree.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ModelTree.cc b/ModelTree.cc
index 5b262870..20490239 100644
--- a/ModelTree.cc
+++ b/ModelTree.cc
@@ -1939,12 +1939,12 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
       if (eq > 0)
         output << ", ";
 
+      BinaryOpNode *eq_node = equations[eq];
+      expr_t lhs = eq_node->get_arg1();
+      expr_t rhs = eq_node->get_arg2();
+
       if (residuals)
         {
-          BinaryOpNode *eq_node = equations[eq];
-          expr_t lhs = eq_node->get_arg1();
-          expr_t rhs = eq_node->get_arg2();
-
           output << "{\"residual\": {"
                  << "\"lhs\": \"";
           lhs->writeJsonOutput(output, temporary_terms, tef_terms);
@@ -1970,8 +1970,10 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
         }
       else
         {
-          output << "{\"equation\": \"";
-          equations[eq]->writeJsonOutput(output, tt_empty, tef_terms);
+          output << "{\"lhs\": \"";
+          lhs->writeJsonOutput(output, tt_empty, tef_terms);
+          output << "\", \"rhs\": \"";
+          rhs->writeJsonOutput(output, tt_empty, tef_terms);
           output << "\""
                  << ", \"line\": " << equations_lineno[eq];
 
-- 
GitLab