/usr/include/trilinos/RTC_commonRTC.hh is in libtrilinos-pamgen-dev 12.4.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | #ifndef _COMMONRTC_H
#define _COMMONRTC_H
#include <string>
#include <typeinfo>
#include <cmath>
namespace PG_RuntimeCompiler {
//errs must be defined
#define CHECKERR(c,m) \
if(c) { errs += "Error at line " + intToString(tokens.lineNum()) + ": " + m; return; }
#define CHECKARGERR(c,m) \
if(c) { errs += m; return; }
/**
* TokenType is an enum that tell us what type a token is
*/
enum TokenType {CONSTANT, /**< constant value - ex: 4.5, 3, 'a', "str" */
VAR, /**< variable name - ex: i, yTy32 */
OPERATOR, /**< operator - ex: +, -, ^ */
OPENINDEX, /**< open square brace: [ */
CLOSEINDEX, /**< closed square brace: ] */
COMMA, /**< a comma: , */
DECL, /**< a variable declaration keyword - ex: int */
BLOCKOPENER, /**< a blockopening keyword - ex: if, while */
FUNC, /**< a function call - ex: sin(8) */
WHITE, /**< whitespace */
OPENBRACE, /**< open curly brace: { */
CLOSEBRACE, /**< closed curly brace: } */
SEMICOLON /**< a semicolon: ; */
};
std::string tokenTypeToString(TokenType tt);
/**
* A Token is a single item in our program
*/
class Token {
private:
TokenType _type; //!< The type of the token
std::string _value; //!< The value of the token
int _lineLoc; //!< The line number location of this token
public:
/**
* Constructor -> Trivial
*
* @param tt - The token's type
* @param value - The token's value
* @param loc - The line number location of this token
*/
Token(TokenType Ttt, const std::string& Tvalue, int Tloc) {
_value = Tvalue;
_type = Ttt;
_lineLoc = Tloc;
}
Token() { }
/**
* get_type -> Returns the type of the token
*/
TokenType type() const {return _type;}
bool operator!=(const Token& rhs) {
return (_value != rhs._value || _type != rhs._type);
}
bool operator==(const Token& rhs) {
return (_value == rhs._value && _type == rhs._type);
}
/**
* value -> Returns the value of the token
*/
const std::string& value() const {return _value;}
int lineLoc() const {return _lineLoc;}
std::string toString() const {
return (tokenTypeToString(_type) + "::" + _value);
}
};
/**
* Type
* An enum to specify the type of a value
*/
enum Type {CharT, IntT, FloatT, DoubleT};
/**
* ObjectType
* An enum to specify what an object really is
*/
enum ObjectType {OperatorOT, ScalarNumberOT, ArrayNumberOT, ScalarVarOT,
ArrayIndexOT, ArrayVarOT, FunctionOT};
////////////////HELPER FUNCTIONS////////////////////
/**
* isAssignable -> Tells us if a certain object type can be assigned to
*
* @param type - The type we are inquiring about
*/
bool isAssignable(ObjectType type);
/**
* isValue -> Tells us if a certain object type can be interpreted as a value
*
* @param type - The type we are inquiring about
*/
bool isValue(ObjectType type);
/**
* isVariable -> Tells us if a certain object type can be considered to be a
* variable
*
* @param type - The type we are inquiring about
*/
bool isVariable(ObjectType type);
/**
* isValidVariableChar -> This method returns true if character c can be part
* of a variable name.
*
* @param c - The character we are looking at
*/
bool isValidVariableChar(char c);
/**
* isValidOperatorChar -> This method returns true if character c can be part
* of an operator.
*
* @param c - The character we are looking at
*/
bool isValidOperatorChar(char c);
/**
* isValidNumericChar -> This method returns true if character c can be part
* of a number.
*
* @param c - The character we are looking at
*/
bool isValidNumericChar(char c);
/**
* isWhitespace -> This method returns true if character c is whitespace
*
* @param c - The character we are looking at
*/
bool isWhitespace(char c);
/**
* isLengthTwoOp -> This method returns true if op is a 2-char operator
*
* @param op - The string representation of the operator we are looking at
*/
bool isLengthTwoOp(const std::string& op);
/**
* isInt -> This method returns true if s contains a valid int
*
* @param s - The string we are looking at
*/
bool isInt(const std::string& s);
/**
* isDouble -> This method returns true if s contains a valid double
*
* @param s - The string we are looking at
*/
bool isDouble(const std::string& s);
/**
* isChar -> This method returns true if s contains a valid char
*
* @param s - The string we are looking at
*/
bool isChar(const std::string& s);
/**
*
*/
bool isString(const std::string& s);
/**
* intToString -> This method returns int i in string form. 46 -> "46"
*
* @param i - The integer we are converting into a string
*/
std::string intToString(int i);
std::string typeToString(Type t);
char getNextRealChar(const std::string& str, unsigned int i);
bool isLetter(char c);
bool isExp(char c);
}
#endif
|