/usr/include/BALL/KERNEL/expressionParser.h is in libball1.4-dev 1.4.1+20111206-3.
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 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_KERNEL_EXPRESSIONPARSER_H
#define BALL_KERNEL_EXPRESSIONPARSER_H
#ifndef BALL_KERNEL_EXPRESSION_TREE_H
# include <BALL/KERNEL/expressionTree.h>
#endif
namespace BALL
{
/** Expression Parser.
A simple parser for BALL kernel expressions. It reads a string and constructs
a syntax tree from the boolean expressions contained therein.
\par
\ingroup KernelMiscellaneous
*/
class BALL_EXPORT ExpressionParser
{
public:
/** SyntaxTree.
This internal class should be used in the implementation
of \link ExpressionParser ExpressionParser \endlink only.
\par
*/
class BALL_EXPORT SyntaxTree
{
public:
/** @name Type Definitions
*/
//@{
/// An iterator for the children of a given node
typedef list<SyntaxTree*>::iterator Iterator;
/// A const iterator for the children of a given node
typedef list<SyntaxTree*>::const_iterator ConstIterator;
//@}
/** @name Constructors and Destructors
*/
//@{
/** Default constructor.
*/
SyntaxTree();
/** Detailed constructor.
*/
SyntaxTree(const char* predicate_name, const char* args);
/** Detailed constructor
*/
SyntaxTree(SyntaxTree* left, SyntaxTree* right, ExpressionTree::Type type);
/** Destructor.
*/
virtual ~SyntaxTree();
//@}
/** @name Assignment
*/
//@{
/** Clear method. This method brings this instance to the state after
default construction. <b>Note</b> that the list of children will be
cleared but the childrem themselves will \emph{not} be deleted.
*/
virtual void clear();
//@}
/** @name Accessors
*/
//@{
/** Return a mutable iterator pointing to the first child.
*/
Iterator begin();
/** Return a mutable iterator pointing to the last child.
*/
Iterator end();
/** Return a constant iterator pointing to the first child.
*/
ConstIterator begin() const;
/** Return a constant iterator pointing to the last child.
*/
ConstIterator end() const;
//@}
/** @name Debugging
*/
//@{
void dump(std::ostream& is = std::cout, Size depth = 0) const;
//@}
/** @name Public attributes
*/
//@{
/**
*/
String expression;
/** ?????
*/
String predicate;
/** ?????
*/
String argument;
/** ?????
*/
bool evaluated;
/** ?????
*/
bool negate;
/** ?????
*/
ExpressionTree::Type type;
/** ?????
*/
list<SyntaxTree*> children;
//@}
};
/** @name Constructors and Destructors
*/
//@{
///
ExpressionParser();
///
ExpressionParser(const ExpressionParser& parser);
///
~ExpressionParser();
//@}
/** @name Parsing
*/
//@{
/** Parse an expression.
* @throw Exception::ParseError if a syntax error was encountered
*/
void parse(const String& s);
/** Return the parsed system
* @throw Exception::NullPointer if the syntax tree is NULL
*/
const SyntaxTree& getSyntaxTree() const;
//@}
struct State
{
Size char_count;
ExpressionParser* current_parser;
const char* buffer;
SyntaxTree* tree;
};
static State state;
protected:
SyntaxTree* syntax_tree_;
static ExpressionParser* current_parser_;
};
} // namespace BALL
#endif // BALL_KERNEL_EXPRESSIONPARSER_H
|