/usr/include/libixion-0.10/ixion/lexer_tokens.hpp is in libixion-dev 0.9.1-3ubuntu1.
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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __IXION_LEXER_TOKENS_HPP__
#define __IXION_LEXER_TOKENS_HPP__
#include "ixion/mem_str_buf.hpp"
#include "ixion/env.hpp"
#include <boost/ptr_container/ptr_vector.hpp>
namespace ixion {
class lexer_token_base;
typedef ::boost::ptr_vector<lexer_token_base> lexer_tokens_t;
std::string print_tokens(const lexer_tokens_t& tokens, bool verbose);
// ============================================================================
enum lexer_opcode_t
{
// data types
op_value,
op_string,
op_name,
// arithmetic operators
op_plus,
op_minus,
op_divide,
op_multiply,
// relational operators
op_equal,
op_less,
op_greater,
// parentheses, separators
op_open,
op_close,
op_sep,
};
const char* get_opcode_name(lexer_opcode_t oc);
// ============================================================================
class lexer_token_base
{
public:
lexer_token_base(lexer_opcode_t oc);
lexer_token_base(const lexer_token_base& r);
virtual ~lexer_token_base();
virtual double get_value() const;
virtual mem_str_buf get_string() const;
virtual ::std::string print() const = 0;
lexer_opcode_t get_opcode() const;
private:
lexer_opcode_t m_opcode;
};
// ============================================================================
class lexer_token : public lexer_token_base
{
public:
lexer_token(lexer_opcode_t oc);
virtual ~lexer_token();
virtual ::std::string print() const;
};
// ============================================================================
class lexer_value_token : public lexer_token_base
{
public:
lexer_value_token(double val);
lexer_value_token(const lexer_value_token& r);
virtual ~lexer_value_token();
virtual double get_value() const;
virtual ::std::string print() const;
private:
double m_val;
};
// ============================================================================
class lexer_string_token : public lexer_token_base
{
public:
lexer_string_token(const char* p, size_t n);
lexer_string_token(const lexer_string_token& r);
virtual ~lexer_string_token();
virtual mem_str_buf get_string() const;
virtual ::std::string print() const;
private:
mem_str_buf m_str;
};
// ============================================================================
class lexer_name_token : public lexer_token_base
{
public:
lexer_name_token(const char* p, size_t n);
lexer_name_token(const lexer_name_token& r);
virtual ~lexer_name_token();
virtual mem_str_buf get_string() const;
virtual ::std::string print() const;
private:
mem_str_buf m_str;
};
// ============================================================================
// We need the following inline functions for boost::ptr_container.
inline lexer_token_base* new_clone(const lexer_token_base& r)
{
lexer_opcode_t oc = r.get_opcode();
switch (oc)
{
case op_value:
return new lexer_value_token(r.get_value());
case op_string:
return new lexer_string_token(static_cast<const lexer_string_token&>(r));
case op_name:
return new lexer_name_token(static_cast<const lexer_name_token&>(r));
case op_close:
case op_divide:
case op_minus:
case op_multiply:
case op_equal:
case op_less:
case op_greater:
case op_open:
case op_plus:
case op_sep:
default:
;
}
return new lexer_token(oc);
}
inline void delete_clone(const lexer_token_base* p)
{
delete p;
}
// ============================================================================
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|