1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseOperStruct(FileInfo,SharedInfo)
// function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseOperStruct(FileInfo,SharedInfo)
// -----------------------------------------------------------------
//#RNU_RES_B
// Parses the Operation structure of the AST.
//
// Structure of Operation:
//overloading function for "operation" type tlist string function
//this is a node of the AST
//fields:
// operands: a list
// operator: a string
// txt=['Operation'
// ' Operands:'
// ' '+objectlist2string(O.operands)
// ' Operator: '+O.operator
// 'EndOperation'
// ]
//
//#RNU_RES_E
// Input data:
// //NUT: add description here
//
// Output data:
// //NUT: add description here
//
// Status:
// 11-Apr-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------
// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),2,2);
// -----------------------
// --- Initialization. ---
// -----------------------
nxtscifunname = SharedInfo.NextSCIFunName;
nxtscifunnumber = SharedInfo.NextSCIFunNumber;
ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
PrintStringInfo(' ',ReportFileName,'file','y');
PrintStringInfo('***Reading AST***',ReportFileName,'file','y');
global SCI2CSTACK
global StackPosition;
global STACKDEDUG
// ---------------------------
// --- End Initialization. ---
// ---------------------------
// ------------------------------
// --- Extract function name. ---
// ------------------------------
buffstring = AST_PopASTStack();
LabelFunctName = 'Operator: ';
FunctionName = stripblanks(part(buffstring,length(LabelFunctName)+1:length(buffstring)));
// Generate the proper function name.
FunctionName = Operator2FunName(FunctionName);
PrintStringInfo(' '+FunctionName,ReportFileName,'file','y');
if (FunctionName == 'OpLogAnd' | FunctionName=='OpLogOr')
NInArg = 0;
NOutArg = 0;
InArg=[];
//RhsField = AST_PopASTStack();
//PrintStringInfo('hello'+RhsField,ReportFileName,'file','y');
//RhsField = AST_PopASTStack();
return ;
end
// ------------------------------
// --- Read input parameters. ---
// ------------------------------
RhsField = AST_PopASTStack();
NInArg = 0;
while (RhsField ~= 'Operands:')
NInArg = NInArg + 1;
[InputArgumentNames(NInArg),InputArgumentScope(NInArg)] = AST_ExtractNameAndScope(RhsField);
RhsField = AST_PopASTStack();
if (RhsField == 'Operation')
error(9999, 'Found Operation before Rhs');
end
end
if (stripblanks(InputArgumentNames(NInArg)) == '<empty>')
//NUT: forse non serve per l'operation
NInArg = 0;
InputArgumentNames = [];
InputArgumentScope = [];
end
InputArgumentNames = SCI2Cflipud(InputArgumentNames);
InputArgumentScope = SCI2Cflipud(InputArgumentScope);
//#RNU_RES_B
// Remove tag "Operation" from the stack.
//#RNU_RES_E
OperationField = AST_PopASTStack();
if (OperationField ~= 'Operation') then
error(9999, 'Problems with Operation, Expected Operation tag.');
end
// --------------------------------------------
// --- Extract number of output parameters. ---
// --------------------------------------------
if (FunctionName == 'ins')
NOutArg = 0; // It is always 1. Double check it!
else
NOutArg = 1; // It is always 1. Double check it!
end
// -------------------------------------
// --- Generate the InArg structure. ---
// -------------------------------------
InArg = [];
for counterinputargs = 1:NInArg
InArg(counterinputargs).Name=InputArgumentNames(counterinputargs);
InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs);
end
//#RNU_RES_B
PrintStringInfo('Operation Name: '+FunctionName,ReportFileName,'file','y');
PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y');
PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y');
//#RNU_RES_E
for counterinputargs = 1:NInArg
//#RNU_RES_B
PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,...
ReportFileName,'file','y');
PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,...
ReportFileName,'file','y');
//#RNU_RES_E
end
endfunction
|