Loading...
Searching...
No Matches
FuncExprData.h
Go to the documentation of this file.
//# FuncExprData.h: Data and enumerations for functional expressions
//# Copyright (C) 2001,2002
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef SCIMATH_FUNCEXPRDATA_H
#define SCIMATH_FUNCEXPRDATA_H
//# Includes
#include <casacore/casa/aips.h>
#include <casacore/casa/BasicSL/String.h>
#include <casacore/casa/stdmap.h>
//# Forward Declarations
#include <casacore/casa/iosfwd.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
// <summary> Data and enumerations for functional expressions
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class=Function>Function</linkto> class
// </prerequisite>
//
// <synopsis>
// This class provides enumerations for expression analysis; and data element
// descriptions
// </synopsis>
//
// <example>
// </example>
//
// <motivation>
// To tie the Glish language to non-linear fitting procedures
// </motivation>
//
// <thrown>
// <li>
// </thrown>
//
// <todo asof="2001/11/21">
// <li> nothing directly
// </todo>
class FuncExprData {
public:
//# Enumerations
// Operations
enum opTypes {
NOP=0,
UNAMIN,
UNAPLUS,
NON,
POW,
GTE,
LTE,
EQ,
NEQ,
OR,
AND,
CONDEX,
CONDEX2,
CONDEX3,
ADD,
SUB,
MUL,
DIV,
LT,
GT,
CONST,
PARAM,
ARG,
TOIMAG,
LBRACE,
RBRACE,
LPAREN,
RPAREN,
LBR,
RBR,
COMMA,
FINISH,
GOTO,
GOTOF,
GOTOT,
SIN,
COS,
ATAN,
ATAN2,
ASIN,
ACOS,
EXP,
EXP10,
EXP2,
LOG,
LOG10,
LOG2,
ERF,
ERFC,
PI,
EE,
ABS,
FLOOR,
CEIL,
ROUND,
INT,
FRACT,
SQRT,
COMPLEX,
REAL,
IMAG,
AMPL,
PHASE,
// Number
NopTypes };
// Operation category
enum opCategories {
// Unary, binary 1 or 2 character
UNA2, UNA1, BIN2, BIN1,
// Special and functions
SPEC, FUNC,
// Number
NopCategories };
// Special categories
enum specAction {
NONE,
// Save environment while compiling
SAVENV,
// Indicate a GOTO
GOTOPC,
// Final expression codes
FINAL };
// Special priority levels
enum specPriority {
// Lowest priority at which right-to-left rather than left-to-right
// execution
RTLPRI = 44,
// Priority for specials - start
SPCPRI = 60,
// Priority for finals
FINPRI = 00 };
// The compilation state descriptor
struct ExprCompState {
// Old index of low RPS boundary
uInt rpslow;
// # of values available on value stack
uInt nval;
// Argument count
uInt argcnt;
// Previous saved program counter
uInt pcptr;
};
// The operator description: code; priority; # of arguments; # of arguments
// used up (or produced for functions)
struct ExprOperator {
// The operator code
opTypes code;
// The name (or characters)
String name;
// The category
opCategories category;
// Execution priority
uInt priority;
// # of arguments necessary (or minimum)
uInt narg;
// max # of arguments (for function)
uInt nmaxarg;
// # of results produced/used
Int nresult;
// code info (like par/x index; jump distance
Int info;
// special action
specAction special;
// state
ExprCompState state;
};
//# Constructors
// Construct the data for the expression analysis
FuncExprData();
// Destructor
~FuncExprData() {}
//# Member functions
// Accessors of the various maps
// <group>
map<String, ExprOperator> &unary2() { return una2_p; }
const map<String, ExprOperator> &unary2() const { return una2_p; }
map<String, ExprOperator> &unary1() { return una1_p; }
const map<String, ExprOperator> &unary1() const { return una1_p; }
map<String, ExprOperator> &binary2() { return bin2_p; }
const map<String, ExprOperator> &binary2() const { return bin2_p; }
map<String, ExprOperator> &binary1() { return bin1_p; }
const map<String, ExprOperator> &binary1() const { return bin1_p; }
map<String, ExprOperator> &special() { return spop_p; }
const map<String, ExprOperator> &special() const { return spop_p; }
map<String, ExprOperator> &function() { return func_p; }
const map<String, ExprOperator> &function() const { return func_p; }
// </group>
// Print an operator map
void print(ostream &os,
const map<String, FuncExprData::ExprOperator> &m) const;
// Print an operation
void print(ostream &os, const FuncExprData::ExprOperator &pos) const;
private:
//# Data
// Unary operators of 2 characters
map<String, ExprOperator> una2_p;
// Unary operators of 1 character
map<String, ExprOperator> una1_p;
// Binary operators of 2 characters
map<String, ExprOperator> bin2_p;
// Binary operators of 1 character
map<String, ExprOperator> bin1_p;
// Special operators
map<String, ExprOperator> spop_p;
// Function names
map<String, ExprOperator> func_p;
// All operators
map<opTypes, ExprOperator> allop_p;
};
//# Global Functions
// <summary> Output function </summary>
// <group name=output>
// Show a list of all defined operators and functions
ostream &operator<<(ostream &os, const FuncExprData &ed);
// </group>
} //# NAMESPACE CASACORE - END
#endif
casacore::FuncExprData
Definition FuncExprData.h:71
casacore::FuncExprData::spop_p
map< String, ExprOperator > spop_p
Special operators.
Definition FuncExprData.h:245
casacore::FuncExprData::allop_p
map< opTypes, ExprOperator > allop_p
All operators.
Definition FuncExprData.h:249
casacore::FuncExprData::function
const map< String, ExprOperator > & function() const
Definition FuncExprData.h:226
casacore::FuncExprData::specPriority
specPriority
Special priority levels.
Definition FuncExprData.h:160
casacore::FuncExprData::FINPRI
@ FINPRI
Priority for finals.
Definition FuncExprData.h:167
casacore::FuncExprData::SPCPRI
@ SPCPRI
Priority for specials - start.
Definition FuncExprData.h:165
casacore::FuncExprData::RTLPRI
@ RTLPRI
Lowest priority at which right-to-left rather than left-to-right execution.
Definition FuncExprData.h:163
casacore::FuncExprData::print
void print(ostream &os, const FuncExprData::ExprOperator &pos) const
Print an operation.
casacore::FuncExprData::special
const map< String, ExprOperator > & special() const
Definition FuncExprData.h:224
casacore::FuncExprData::func_p
map< String, ExprOperator > func_p
Function names.
Definition FuncExprData.h:247
casacore::FuncExprData::specAction
specAction
Special categories.
Definition FuncExprData.h:151
casacore::FuncExprData::SAVENV
@ SAVENV
Save environment while compiling.
Definition FuncExprData.h:154
casacore::FuncExprData::FINAL
@ FINAL
Final expression codes.
Definition FuncExprData.h:158
casacore::FuncExprData::GOTOPC
@ GOTOPC
Indicate a GOTO.
Definition FuncExprData.h:156
casacore::FuncExprData::NONE
@ NONE
Definition FuncExprData.h:152
casacore::FuncExprData::bin1_p
map< String, ExprOperator > bin1_p
Binary operators of 1 character.
Definition FuncExprData.h:243
casacore::FuncExprData::bin2_p
map< String, ExprOperator > bin2_p
Binary operators of 2 characters.
Definition FuncExprData.h:241
casacore::FuncExprData::binary1
map< String, ExprOperator > & binary1()
Definition FuncExprData.h:221
casacore::FuncExprData::binary2
map< String, ExprOperator > & binary2()
Definition FuncExprData.h:219
casacore::FuncExprData::una1_p
map< String, ExprOperator > una1_p
Unary operators of 1 character.
Definition FuncExprData.h:239
casacore::FuncExprData::unary2
map< String, ExprOperator > & unary2()
Accessors of the various maps.
Definition FuncExprData.h:215
casacore::FuncExprData::binary2
const map< String, ExprOperator > & binary2() const
Definition FuncExprData.h:220
casacore::FuncExprData::unary2
const map< String, ExprOperator > & unary2() const
Definition FuncExprData.h:216
casacore::FuncExprData::binary1
const map< String, ExprOperator > & binary1() const
Definition FuncExprData.h:222
casacore::FuncExprData::opCategories
opCategories
Operation category.
Definition FuncExprData.h:143
casacore::FuncExprData::NopCategories
@ NopCategories
Number.
Definition FuncExprData.h:149
casacore::FuncExprData::BIN1
@ BIN1
Definition FuncExprData.h:145
casacore::FuncExprData::BIN2
@ BIN2
Definition FuncExprData.h:145
casacore::FuncExprData::SPEC
@ SPEC
Special and functions.
Definition FuncExprData.h:147
casacore::FuncExprData::UNA1
@ UNA1
Definition FuncExprData.h:145
casacore::FuncExprData::FUNC
@ FUNC
Definition FuncExprData.h:147
casacore::FuncExprData::UNA2
@ UNA2
Unary, binary 1 or 2 character.
Definition FuncExprData.h:145
casacore::FuncExprData::opTypes
opTypes
Operations.
Definition FuncExprData.h:75
casacore::FuncExprData::IMAG
@ IMAG
Definition FuncExprData.h:136
casacore::FuncExprData::COS
@ COS
Definition FuncExprData.h:112
casacore::FuncExprData::ERF
@ ERF
Definition FuncExprData.h:123
casacore::FuncExprData::EE
@ EE
Definition FuncExprData.h:126
casacore::FuncExprData::SIN
@ SIN
Definition FuncExprData.h:111
casacore::FuncExprData::LBR
@ LBR
Definition FuncExprData.h:104
casacore::FuncExprData::FRACT
@ FRACT
Definition FuncExprData.h:132
casacore::FuncExprData::ADD
@ ADD
Definition FuncExprData.h:90
casacore::FuncExprData::RPAREN
@ RPAREN
Definition FuncExprData.h:103
casacore::FuncExprData::LOG2
@ LOG2
Definition FuncExprData.h:122
casacore::FuncExprData::INT
@ INT
Definition FuncExprData.h:131
casacore::FuncExprData::LTE
@ LTE
Definition FuncExprData.h:82
casacore::FuncExprData::CONDEX2
@ CONDEX2
Definition FuncExprData.h:88
casacore::FuncExprData::ROUND
@ ROUND
Definition FuncExprData.h:130
casacore::FuncExprData::EXP
@ EXP
Definition FuncExprData.h:117
casacore::FuncExprData::ACOS
@ ACOS
Definition FuncExprData.h:116
casacore::FuncExprData::REAL
@ REAL
Definition FuncExprData.h:135
casacore::FuncExprData::ATAN
@ ATAN
Definition FuncExprData.h:113
casacore::FuncExprData::ARG
@ ARG
Definition FuncExprData.h:98
casacore::FuncExprData::GOTOT
@ GOTOT
Definition FuncExprData.h:110
casacore::FuncExprData::RBRACE
@ RBRACE
Definition FuncExprData.h:101
casacore::FuncExprData::AND
@ AND
Definition FuncExprData.h:86
casacore::FuncExprData::FLOOR
@ FLOOR
Definition FuncExprData.h:128
casacore::FuncExprData::COMPLEX
@ COMPLEX
Definition FuncExprData.h:134
casacore::FuncExprData::RBR
@ RBR
Definition FuncExprData.h:105
casacore::FuncExprData::MUL
@ MUL
Definition FuncExprData.h:92
casacore::FuncExprData::EQ
@ EQ
Definition FuncExprData.h:83
casacore::FuncExprData::GT
@ GT
Definition FuncExprData.h:95
casacore::FuncExprData::DIV
@ DIV
Definition FuncExprData.h:93
casacore::FuncExprData::SQRT
@ SQRT
Definition FuncExprData.h:133
casacore::FuncExprData::AMPL
@ AMPL
Definition FuncExprData.h:137
casacore::FuncExprData::EXP10
@ EXP10
Definition FuncExprData.h:118
casacore::FuncExprData::CONST
@ CONST
Definition FuncExprData.h:96
casacore::FuncExprData::NON
@ NON
Definition FuncExprData.h:79
casacore::FuncExprData::POW
@ POW
Definition FuncExprData.h:80
casacore::FuncExprData::OR
@ OR
Definition FuncExprData.h:85
casacore::FuncExprData::LPAREN
@ LPAREN
Definition FuncExprData.h:102
casacore::FuncExprData::LT
@ LT
Definition FuncExprData.h:94
casacore::FuncExprData::CEIL
@ CEIL
Definition FuncExprData.h:129
casacore::FuncExprData::CONDEX
@ CONDEX
Definition FuncExprData.h:87
casacore::FuncExprData::LOG
@ LOG
Definition FuncExprData.h:120
casacore::FuncExprData::ASIN
@ ASIN
Definition FuncExprData.h:115
casacore::FuncExprData::GOTO
@ GOTO
Definition FuncExprData.h:108
casacore::FuncExprData::NopTypes
@ NopTypes
Number.
Definition FuncExprData.h:140
casacore::FuncExprData::PHASE
@ PHASE
Definition FuncExprData.h:138
casacore::FuncExprData::COMMA
@ COMMA
Definition FuncExprData.h:106
casacore::FuncExprData::UNAMIN
@ UNAMIN
Definition FuncExprData.h:77
casacore::FuncExprData::NOP
@ NOP
Definition FuncExprData.h:76
casacore::FuncExprData::ATAN2
@ ATAN2
Definition FuncExprData.h:114
casacore::FuncExprData::NEQ
@ NEQ
Definition FuncExprData.h:84
casacore::FuncExprData::ERFC
@ ERFC
Definition FuncExprData.h:124
casacore::FuncExprData::EXP2
@ EXP2
Definition FuncExprData.h:119
casacore::FuncExprData::PI
@ PI
Definition FuncExprData.h:125
casacore::FuncExprData::UNAPLUS
@ UNAPLUS
Definition FuncExprData.h:78
casacore::FuncExprData::SUB
@ SUB
Definition FuncExprData.h:91
casacore::FuncExprData::GOTOF
@ GOTOF
Definition FuncExprData.h:109
casacore::FuncExprData::FINISH
@ FINISH
Definition FuncExprData.h:107
casacore::FuncExprData::LOG10
@ LOG10
Definition FuncExprData.h:121
casacore::FuncExprData::CONDEX3
@ CONDEX3
Definition FuncExprData.h:89
casacore::FuncExprData::GTE
@ GTE
Definition FuncExprData.h:81
casacore::FuncExprData::ABS
@ ABS
Definition FuncExprData.h:127
casacore::FuncExprData::TOIMAG
@ TOIMAG
Definition FuncExprData.h:99
casacore::FuncExprData::PARAM
@ PARAM
Definition FuncExprData.h:97
casacore::FuncExprData::LBRACE
@ LBRACE
Definition FuncExprData.h:100
casacore::FuncExprData::function
map< String, ExprOperator > & function()
Definition FuncExprData.h:225
casacore::FuncExprData::unary1
const map< String, ExprOperator > & unary1() const
Definition FuncExprData.h:218
casacore::FuncExprData::una2_p
map< String, ExprOperator > una2_p
Unary operators of 2 characters.
Definition FuncExprData.h:237
casacore::FuncExprData::unary1
map< String, ExprOperator > & unary1()
Definition FuncExprData.h:217
casacore::FuncExprData::print
void print(ostream &os, const map< String, FuncExprData::ExprOperator > &m) const
Print an operator map.
casacore::FuncExprData::FuncExprData
FuncExprData()
Construct the data for the expression analysis.
casacore::FuncExprData::~FuncExprData
~FuncExprData()
Destructor.
Definition FuncExprData.h:210
casacore::FuncExprData::special
map< String, ExprOperator > & special()
Definition FuncExprData.h:223
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::map
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::operator<<
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::Int
int Int
Definition aipstype.h:48
casacore::FuncExprData::ExprCompState
The compilation state descriptor.
Definition FuncExprData.h:170
casacore::FuncExprData::ExprCompState::argcnt
uInt argcnt
Argument count.
Definition FuncExprData.h:176
casacore::FuncExprData::ExprCompState::pcptr
uInt pcptr
Previous saved program counter.
Definition FuncExprData.h:178
casacore::FuncExprData::ExprCompState::nval
uInt nval
Definition FuncExprData.h:174
casacore::FuncExprData::ExprCompState::rpslow
uInt rpslow
Old index of low RPS boundary.
Definition FuncExprData.h:172
casacore::FuncExprData::ExprOperator
The operator description: code; priority; # of arguments; # of arguments used up (or produced for fun...
Definition FuncExprData.h:182
casacore::FuncExprData::ExprOperator::nmaxarg
uInt nmaxarg
max # of arguments (for function)
Definition FuncExprData.h:194
casacore::FuncExprData::ExprOperator::special
specAction special
special action
Definition FuncExprData.h:200
casacore::FuncExprData::ExprOperator::narg
uInt narg
Definition FuncExprData.h:192
casacore::FuncExprData::ExprOperator::info
Int info
code info (like par/x index; jump distance
Definition FuncExprData.h:198
casacore::FuncExprData::ExprOperator::code
opTypes code
The operator code.
Definition FuncExprData.h:184
casacore::FuncExprData::ExprOperator::name
String name
The name (or characters).
Definition FuncExprData.h:186
casacore::FuncExprData::ExprOperator::state
ExprCompState state
state
Definition FuncExprData.h:202
casacore::FuncExprData::ExprOperator::nresult
Int nresult
Definition FuncExprData.h:196
casacore::FuncExprData::ExprOperator::category
opCategories category
The category.
Definition FuncExprData.h:188
casacore::FuncExprData::ExprOperator::priority
uInt priority
Execution priority.
Definition FuncExprData.h:190
casacore::FuncExprData_global_functions_output
Output function .
Definition FuncExprData.h:257
casacore::FuncExprData_global_functions_output::operator<<
ostream & operator<<(ostream &os, const FuncExprData &ed)
Show a list of all defined operators and functions.