/usr/include/trilinos/token.h is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
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 | // $Id$
#ifndef tokenH
#define tokenH
#include <stdio.h>
#include <setjmp.h>
#include "../asrc/code_types.h"
#include "token_enum.h"
#include "token_value.h"
#include <string>
#include <assert.h>
namespace PAMGEN_NEVADA{
/*****************************************************************************/
class Token
/*****************************************************************************/
// Represents a token -- the atom of input recognized by the scanner and
// passed to the parser.
{
public:
// The token type defaults to the exit token.
Token();
// In general, a token consists of a type and an associated
// semantic value
Token(Token_Type t, Token_Value& sv);
// Not all tokens have an associated semantic value.
// However, we do *not* want an implicit conversion from integral
// types to Token, so we add a dummy argument.
enum No_Value { no_value };
Token(Token_Type t, No_Value);
Token(const Token &src);
~Token();
Token& operator=(const Token&);
Token_Type Type() const {return type;}
void Convert_Real(Real& x) {s.fval = x;}
int As_Int() const
{
assert(Type()==TK_INTEGER);
return s.ival;
}
Real As_Real() const
{
assert(Type()==TK_REAL || Type()==TK_INTEGER);
if(Type()==TK_INTEGER) return s.ival;
//Type()==TK_REAL
return s.fval;
}
const char* As_String() const
{
assert(Type()==TK_IDENTIFIER || Type()==TK_STRING);
return s.sval;
}
// Return the value of a quoted string token with its
// quotes stripped away.
std::string As_Stripped_String() const;
friend bool operator==(const Token &, const Token &);
friend bool operator!=(const Token &, const Token &);
friend bool operator==(const Token& tk, const char *c){
return (int)tk.type == (int)TK_IDENTIFIER && !Token_Match(tk.s.sval, c);
}
friend bool operator==(const char *c, const Token& tk){
return (int)tk.type == (int)TK_IDENTIFIER && !Token_Match(tk.s.sval, c);
}
friend bool operator!=(const Token& tk, const char *c){
return (int)tk.type != (int)TK_IDENTIFIER || Token_Match(tk.s.sval, c);
}
friend bool operator!=(const char *c, const Token& tk){
return (int)tk.type != (int)TK_IDENTIFIER || Token_Match(tk.s.sval, c);
}
// Matches two character strings according to the following rules:
// Two character strings t and k match if each word of t matches
// each word of k.
// Two words match if word from t matches the first part of word
// from k.
static int Token_Match(const char *t, const char *k);
private:
Token_Type type;
Token_Value s;
void copy(const Token&);
void free_resources();
};
}//end namespace
#endif
|