2008-11-05 03:57:18 +01:00
|
|
|
#ifndef ARABICA_XSLT_PRECEDENCE_HPP
|
|
|
|
#define ARABICA_XSLT_PRECEDENCE_HPP
|
|
|
|
|
|
|
|
class Precedence
|
|
|
|
{
|
|
|
|
public:
|
2008-11-05 23:55:53 +01:00
|
|
|
static Precedence InitialPrecedence()
|
|
|
|
{
|
|
|
|
static Precedence initial_(0);
|
|
|
|
return initial_;
|
|
|
|
} // Precedence
|
|
|
|
|
|
|
|
static Precedence FrozenPrecedence()
|
|
|
|
{
|
|
|
|
static Precedence frozen_(-1);
|
|
|
|
return frozen_;
|
|
|
|
} // Precedence
|
|
|
|
|
2008-11-05 03:57:18 +01:00
|
|
|
Precedence() :
|
|
|
|
precedence_()
|
|
|
|
{
|
2008-11-05 23:55:53 +01:00
|
|
|
//precedence_.push_back(0);
|
2008-11-05 03:57:18 +01:00
|
|
|
} // Precedence
|
|
|
|
|
|
|
|
Precedence(const Precedence& rhs) :
|
|
|
|
precedence_(rhs.precedence_)
|
|
|
|
{
|
|
|
|
} // Precedence
|
|
|
|
|
|
|
|
private:
|
2008-11-05 23:55:53 +01:00
|
|
|
//Precedence(const std::vector<int> precedence) :
|
|
|
|
Precedence(int precedence) :
|
2008-11-05 03:57:18 +01:00
|
|
|
precedence_(precedence)
|
|
|
|
{
|
|
|
|
} // Precedence
|
|
|
|
|
|
|
|
public:
|
|
|
|
~Precedence() { }
|
|
|
|
|
|
|
|
bool operator==(const Precedence& rhs) const
|
|
|
|
{
|
|
|
|
return precedence_ == rhs.precedence_;
|
|
|
|
} // operator==
|
|
|
|
|
2008-11-05 23:55:53 +01:00
|
|
|
bool operator>(const Precedence& rhs) const
|
|
|
|
{
|
|
|
|
return precedence_ > rhs.precedence_;
|
|
|
|
} // operator>
|
|
|
|
|
2008-11-05 03:57:18 +01:00
|
|
|
Precedence& operator=(const Precedence& rhs)
|
|
|
|
{
|
2008-11-05 23:55:53 +01:00
|
|
|
//std::vector<int> other(rhs.precedence_);
|
|
|
|
//precedence_.swap(other);
|
|
|
|
precedence_ = rhs.precedence_;
|
2008-11-05 03:57:18 +01:00
|
|
|
return *this;
|
|
|
|
} // operator=
|
|
|
|
|
|
|
|
Precedence nextGeneration(int p) const
|
|
|
|
{
|
2008-11-05 23:55:53 +01:00
|
|
|
Precedence next(p);
|
|
|
|
//Precedence next(precedence_);
|
|
|
|
//next.precedence_.push_back(p);
|
2008-11-05 03:57:18 +01:00
|
|
|
return next;
|
|
|
|
} // nextGeneration
|
|
|
|
|
|
|
|
private:
|
2008-11-05 23:55:53 +01:00
|
|
|
// std::vector<int> precedence_;
|
|
|
|
int precedence_;
|
2008-11-05 03:57:18 +01:00
|
|
|
}; // class Precedence
|
|
|
|
|
2008-11-05 23:55:53 +01:00
|
|
|
class PrecedenceStack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PrecedenceStack() :
|
|
|
|
stack_()
|
|
|
|
{
|
|
|
|
stack_.push_back(Precedence::InitialPrecedence());
|
|
|
|
} // PrecedenceStack
|
|
|
|
|
|
|
|
PrecedenceStack(const PrecedenceStack& rhs) :
|
|
|
|
stack_(rhs.stack_)
|
|
|
|
{
|
|
|
|
} // PrecedenceStack
|
|
|
|
|
|
|
|
const Precedence& top() const { return stack_[stack_.size()-1]; }
|
|
|
|
void push() { stack_.push_back(top().nextGeneration(stack_.size())); }
|
|
|
|
void freeze()
|
|
|
|
{
|
|
|
|
stack_.clear();
|
|
|
|
stack_.push_back(Precedence::FrozenPrecedence());
|
|
|
|
} // freeze
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Precedence> stack_;
|
|
|
|
}; // class PrecedenceStack
|
2008-11-05 03:57:18 +01:00
|
|
|
#endif
|