* Bug 16679 fixed: get_function_path('acosh') yielded an error
[scilab.git] / scilab / modules / functions / macros / rhs2code.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA - Vincent Couvert
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13
14 function C=rhs2code(rhs)
15     // Translate rhs list of an instruction to macro code (called by tree2code)
16     // Input:
17     // - rhs: list of rhs arguments
18     // Output:
19     // - C: Scilab code corresponding to rhs
20     // V.C.
21
22     n=size(rhs)
23
24     C=""
25     if typeof(rhs)<>"list" then
26         C=expression2code(rhs)
27     else
28         for k=1:n
29             therhs = expression2code(rhs(k));
30             if k==1 then
31                 C = therhs;
32             else
33                 if therhs == "(EOL)" then
34                     C = [C;""];
35                 else
36                     if C($)=="" then
37                         // Previous rhs was a EOL
38                         C = [C(1:($-2));
39                         C($-1)+"..";
40                         C($) + therhs(1);
41                         therhs(2:$)];
42                     else
43                         C = [C(1:($-1));
44                         C($) + "," + therhs(1);
45                         therhs(2:$)];
46                     end
47                 end
48             end
49         end
50     end
51
52
53 endfunction