1function [lhs, rhs] = get_lhs_and_rhs(eqname, DynareModel, original)
2
3% Returns the left and right handsides of an equation.
4%
5% INPUTS
6% - lhs         [string]            Left hand side of the equation.
7% - rhs         [string]            Right hand side of the equation.
8% - DynareModel [struct]            Structure describing the current model (M_).
9%
10% OUTPUTS
11% - eqname      [string]            Name of the equation.
12%
13% SPECIAL REQUIREMENTS
14%  The user must have attached names to the equations using equation
15%  tags. Each equation in the model block must be preceeded with a
16%  tag (see the reference manual). For instance, we should have
17%  something as:
18%
19%      [name='Phillips curve']
20%      pi = beta*pi(1) + slope*y + lam;
21
22% Copyright (C) 2018 Dynare Team
23%
24% This file is part of Dynare.
25%
26% Dynare is free software: you can redistribute it and/or modify
27% it under the terms of the GNU General Public License as published by
28% the Free Software Foundation, either version 3 of the License, or
29% (at your option) any later version.
30%
31% Dynare is distributed in the hope that it will be useful,
32% but WITHOUT ANY WARRANTY; without even the implied warranty of
33% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34% GNU General Public License for more details.
35%
36% You should have received a copy of the GNU General Public License
37% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
38
39if nargin<3
40    original = false;
41end
42
43% Get the equation from the JSON output.
44if original
45    jsonfil = loadjson([DynareModel.fname filesep() 'model' filesep() 'json' filesep() 'modfile-original.json']);
46else
47    jsonfil = loadjson([DynareModel.fname filesep() 'model' filesep() 'json' filesep() 'modfile.json']);
48end
49jsonmod = jsonfil.model;
50jsoneqn = getEquationsByTags(jsonmod, 'name', eqname);
51
52% Get the lhs and rhs members of the selected equation.
53lhs = jsoneqn{1}.lhs;
54rhs = jsoneqn{1}.rhs;