Started work on refactoring precedence handling. Need to try and preserver the tree shape it forms, rather than a simple case of monotonically increasing precen

I mean decreasing precedence.
This commit is contained in:
jez 2008-11-05 02:57:18 +00:00
parent 2b2c09b1f3
commit e8c0aaa416
2 changed files with 53 additions and 2 deletions

View file

@ -0,0 +1,50 @@
#ifndef ARABICA_XSLT_PRECEDENCE_HPP
#define ARABICA_XSLT_PRECEDENCE_HPP
class Precedence
{
public:
Precedence() :
precedence_()
{
} // Precedence
Precedence(const Precedence& rhs) :
precedence_(rhs.precedence_)
{
} // Precedence
private:
Precedence(const std::vector<int> precedence) :
precedence_(precedence)
{
} // Precedence
public:
~Precedence() { }
bool operator==(const Precedence& rhs) const
{
return precedence_ == rhs.precedence_;
} // operator==
Precedence& operator=(const Precedence& rhs)
{
std::vector<int> other(rhs.precedence_);
precedence_.swap(other);
return *this;
} // operator=
Precedence nextGeneration(int p) const
{
Precedence next(precedence_);
next.precedence_.push_back(p);
return next;
} // nextGeneration
private:
std::vector<int> precedence_;
}; // class Precedence
#endif

View file

@ -2,6 +2,7 @@
#define ARABICA_XSLT_TEMPLATE_HPP
#include "xslt_item.hpp"
#include "xslt_precedence.hpp"
namespace Arabica
{
@ -12,8 +13,8 @@ class Template : public ItemContainer
{
public:
Template(const std::pair<std::string, std::string>& name,
const std::pair<std::string, std::string>& mode,
const std::string& priority) :
const std::pair<std::string, std::string>& mode,
const std::string& priority) :
matches_(),
name_(name),
mode_(mode)