casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FuncExprData.h
Go to the documentation of this file.
1 //# FuncExprData.h: Data and enumerations for functional expressions
2 //# Copyright (C) 2001,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef SCIMATH_FUNCEXPRDATA_H
30 #define SCIMATH_FUNCEXPRDATA_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 #include <casacore/casa/stdmap.h>
36 
37 //# Forward Declarations
38 #include <casacore/casa/iosfwd.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 // <summary> Data and enumerations for functional expressions
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class=Function>Function</linkto> class
52 // </prerequisite>
53 //
54 // <synopsis>
55 // This class provides enumerations for expression analysis; and data element
56 // descriptions
57 // </synopsis>
58 //
59 // <example>
60 // </example>
61 //
62 // <motivation>
63 // To tie the Glish language to non-linear fitting procedures
64 // </motivation>
65 //
66 // <thrown>
67 // <li>
68 // </thrown>
69 //
70 // <todo asof="2001/11/21">
71 // <li> nothing directly
72 // </todo>
73 
74 class FuncExprData {
75 public:
76  //# Enumerations
77  // Operations
78  enum opTypes {
79  NOP=0,
82  NON,
83  POW,
84  GTE,
85  LTE,
86  EQ,
87  NEQ,
88  OR,
89  AND,
93  ADD,
94  SUB,
95  MUL,
96  DIV,
97  LT,
98  GT,
128  PI,
129  EE,
142  // Number
144 
145  // Operation category
147  // Unary, binary 1 or 2 character
149  // Special and functions
151  // Number
153  // Special categories
154  enum specAction {
156  // Save environment while compiling
158  // Indicate a GOTO
160  // Final expression codes
161  FINAL };
162  // Special priority levels
164  // Lowest priority at which right-to-left rather than left-to-right
165  // execution
166  RTLPRI = 44,
167  // Priority for specials - start
168  SPCPRI = 60,
169  // Priority for finals
170  FINPRI = 00 };
171 
172  // The compilation state descriptor
173  struct ExprCompState {
174  // Old index of low RPS boundary
176  // # of values available on value stack
178  // Argument count
180  // Previous saved program counter
182  };
183  // The operator description: code; priority; # of arguments; # of arguments
184  // used up (or produced for functions)
185  struct ExprOperator {
186  // The operator code
188  // The name (or characters)
190  // The category
192  // Execution priority
194  // # of arguments necessary (or minimum)
196  // max # of arguments (for function)
198  // # of results produced/used
200  // code info (like par/x index; jump distance
202  // special action
204  // state
206  };
207 
208  //# Constructors
209  // Construct the data for the expression analysis
210  FuncExprData();
211 
212  // Destructor
214 
215  //# Member functions
216  // Accessors of the various maps
217  // <group>
218  map<String, ExprOperator> &unary2() { return una2_p; }
219  const map<String, ExprOperator> &unary2() const { return una2_p; }
220  map<String, ExprOperator> &unary1() { return una1_p; }
221  const map<String, ExprOperator> &unary1() const { return una1_p; }
222  map<String, ExprOperator> &binary2() { return bin2_p; }
223  const map<String, ExprOperator> &binary2() const { return bin2_p; }
224  map<String, ExprOperator> &binary1() { return bin1_p; }
225  const map<String, ExprOperator> &binary1() const { return bin1_p; }
226  map<String, ExprOperator> &special() { return spop_p; }
227  const map<String, ExprOperator> &special() const { return spop_p; }
228  map<String, ExprOperator> &function() { return func_p; }
229  const map<String, ExprOperator> &function() const { return func_p; }
230  // </group>
231  // Print an operator map
232  void print(ostream &os,
233  const map<String, FuncExprData::ExprOperator> &m) const;
234  // Print an operation
235  void print(ostream &os, const FuncExprData::ExprOperator &pos) const;
236 
237 private:
238  //# Data
239  // Unary operators of 2 characters
240  map<String, ExprOperator> una2_p;
241  // Unary operators of 1 character
242  map<String, ExprOperator> una1_p;
243  // Binary operators of 2 characters
244  map<String, ExprOperator> bin2_p;
245  // Binary operators of 1 character
246  map<String, ExprOperator> bin1_p;
247  // Special operators
248  map<String, ExprOperator> spop_p;
249  // Function names
250  map<String, ExprOperator> func_p;
251  // All operators
252  map<opTypes, ExprOperator> allop_p;
253 };
254 
255 //# Global Functions
256 
257 // <summary> Output function </summary>
258 
259 // <group name=output>
260 // Show a list of all defined operators and functions
261 ostream &operator<<(ostream &os, const FuncExprData &ed);
262 // </group>
263 
264 
265 } //# NAMESPACE CASACORE - END
266 
267 #endif
268 
269 
270 
Save environment while compiling.
Definition: FuncExprData.h:157
map< opTypes, ExprOperator > allop_p
All operators.
Definition: FuncExprData.h:252
Priority for finals.
Definition: FuncExprData.h:170
uInt narg
of arguments necessary (or minimum)
Definition: FuncExprData.h:195
opCategories category
The category.
Definition: FuncExprData.h:191
map< String, ExprOperator > func_p
Function names.
Definition: FuncExprData.h:250
int Int
Definition: aipstype.h:50
uInt nmaxarg
max # of arguments (for function)
Definition: FuncExprData.h:197
map< String, ExprOperator > una1_p
Unary operators of 1 character.
Definition: FuncExprData.h:242
specPriority
Special priority levels.
Definition: FuncExprData.h:163
const map< String, ExprOperator > & binary1() const
Definition: FuncExprData.h:225
uInt pcptr
Previous saved program counter.
Definition: FuncExprData.h:181
Final expression codes.
Definition: FuncExprData.h:161
map< String, ExprOperator > bin2_p
Binary operators of 2 characters.
Definition: FuncExprData.h:244
Special and functions.
Definition: FuncExprData.h:150
~FuncExprData()
Destructor.
Definition: FuncExprData.h:213
specAction
Special categories.
Definition: FuncExprData.h:154
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
uInt nval
of values available on value stack
Definition: FuncExprData.h:177
map< String, ExprOperator > & special()
Definition: FuncExprData.h:226
const map< String, ExprOperator > & unary1() const
Definition: FuncExprData.h:221
map< String, ExprOperator > bin1_p
Binary operators of 1 character.
Definition: FuncExprData.h:246
The operator description: code; priority; # of arguments; # of arguments used up (or produced for fun...
Definition: FuncExprData.h:185
Unary, binary 1 or 2 character.
Definition: FuncExprData.h:148
map< String, ExprOperator > spop_p
Special operators.
Definition: FuncExprData.h:248
opTypes code
The operator code.
Definition: FuncExprData.h:187
Int info
code info (like par/x index; jump distance
Definition: FuncExprData.h:201
Lowest priority at which right-to-left rather than left-to-right execution.
Definition: FuncExprData.h:166
opCategories
Operation category.
Definition: FuncExprData.h:146
map< String, ExprOperator > & unary2()
Accessors of the various maps.
Definition: FuncExprData.h:218
String name
The name (or characters)
Definition: FuncExprData.h:189
map< String, ExprOperator > una2_p
Unary operators of 2 characters.
Definition: FuncExprData.h:240
void print(ostream &os, const map< String, FuncExprData::ExprOperator > &m) const
Print an operator map.
uInt rpslow
Old index of low RPS boundary.
Definition: FuncExprData.h:175
Priority for specials - start.
Definition: FuncExprData.h:168
specAction special
special action
Definition: FuncExprData.h:203
FuncExprData()
Construct the data for the expression analysis.
Int nresult
of results produced/used
Definition: FuncExprData.h:199
const map< String, ExprOperator > & special() const
Definition: FuncExprData.h:227
map< String, ExprOperator > & binary1()
Definition: FuncExprData.h:224
map< String, ExprOperator > & binary2()
Definition: FuncExprData.h:222
const map< String, ExprOperator > & binary2() const
Definition: FuncExprData.h:223
String: the storage and methods of handling collections of characters.
Definition: String.h:225
map< String, ExprOperator > & unary1()
Definition: FuncExprData.h:220
uInt priority
Execution priority.
Definition: FuncExprData.h:193
const map< String, ExprOperator > & unary2() const
Definition: FuncExprData.h:219
unsigned int uInt
Definition: aipstype.h:51
The compilation state descriptor.
Definition: FuncExprData.h:173
Data and enumerations for functional expressions.
Definition: FuncExprData.h:74