mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
Aha! The push/pop precedence thing is, of course, wrongly wrong. Need to assign the new precedence at the point we encounter the xsl:import, then set that precedence as current when we actually load it. I'll sort that out next time, because it's bedtime for programmers now.
This commit is contained in:
parent
538a8969ad
commit
fe40d482f5
2 changed files with 38 additions and 16 deletions
|
@ -149,6 +149,10 @@ public:
|
|||
precedenceStack_.pop();
|
||||
} // pop_import_precedence
|
||||
|
||||
// void set_precedence(const Prcedence& prec)
|
||||
|
||||
// const Precedence& next_precedence()
|
||||
|
||||
const Precedence& precedence() const
|
||||
{
|
||||
return precedenceStack_.top();
|
||||
|
|
|
@ -28,12 +28,17 @@ public:
|
|||
} // Precedence
|
||||
|
||||
private:
|
||||
//Precedence(const std::vector<int> precedence) :
|
||||
Precedence(int precedence) :
|
||||
Precedence(const std::vector<int> precedence) :
|
||||
precedence_(precedence)
|
||||
{
|
||||
} // Precedence
|
||||
|
||||
Precedence(int precedence) :
|
||||
precedence_()
|
||||
{
|
||||
precedence_.push_back(precedence);
|
||||
} // Precedence
|
||||
|
||||
public:
|
||||
~Precedence() { }
|
||||
|
||||
|
@ -49,37 +54,48 @@ public:
|
|||
|
||||
Precedence& operator=(const Precedence& rhs)
|
||||
{
|
||||
//std::vector<int> other(rhs.precedence_);
|
||||
//precedence_.swap(other);
|
||||
precedence_ = rhs.precedence_;
|
||||
std::vector<int> other(rhs.precedence_);
|
||||
precedence_.swap(other);
|
||||
return *this;
|
||||
} // operator=
|
||||
|
||||
Precedence nextGeneration(int p) const
|
||||
{
|
||||
Precedence next(p);
|
||||
//Precedence next(precedence_);
|
||||
//next.precedence_.push_back(p);
|
||||
Precedence next(precedence_);
|
||||
next.precedence_.push_back(p);
|
||||
return next;
|
||||
} // nextGeneration
|
||||
|
||||
private:
|
||||
// std::vector<int> precedence_;
|
||||
int precedence_;
|
||||
std::vector<int> precedence_;
|
||||
|
||||
friend bool operator<(const Precedence& lhs, const Precedence& rhs);
|
||||
friend std::ostream& operator<<(std::ostream& os, const Precedence& prec);
|
||||
}; // class Precedence
|
||||
|
||||
bool operator<(const Precedence& lhs, const Precedence& rhs)
|
||||
{
|
||||
return lhs.precedence_ < rhs.precedence_;
|
||||
return lhs.precedence_.back() < rhs.precedence_.back();
|
||||
} // PrecedenceCompare
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Precedence& prec)
|
||||
{
|
||||
os << "(";
|
||||
for(std::vector<int>::const_iterator p = prec.precedence_.begin(), pe = prec.precedence_.end(); p != pe; ++p)
|
||||
{
|
||||
if(p != prec.precedence_.begin())
|
||||
os << ",";
|
||||
os << *p;
|
||||
} // for ..
|
||||
os << ")";
|
||||
} // operator<<
|
||||
|
||||
class PrecedenceStack
|
||||
{
|
||||
public:
|
||||
PrecedenceStack() :
|
||||
stack_()
|
||||
stack_(),
|
||||
count_(1)
|
||||
{
|
||||
stack_.push(Precedence::InitialPrecedence());
|
||||
} // PrecedenceStack
|
||||
|
@ -90,7 +106,11 @@ public:
|
|||
} // PrecedenceStack
|
||||
|
||||
const Precedence& top() const { return stack_.top(); }
|
||||
void push() { stack_.push(top().nextGeneration(count_++)); }
|
||||
void push()
|
||||
{
|
||||
stack_.push(top().nextGeneration(count_++));
|
||||
std::cout << "Pushed " << top() << std::endl;
|
||||
}
|
||||
void pop() { stack_.pop(); }
|
||||
void freeze()
|
||||
{
|
||||
|
@ -101,8 +121,6 @@ public:
|
|||
|
||||
private:
|
||||
std::stack<Precedence> stack_;
|
||||
static int count_;
|
||||
int count_;
|
||||
}; // class PrecedenceStack
|
||||
|
||||
int PrecedenceStack::count_ = 0;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue