void DebugExpressionFactory::processTemplateRule(const Expression::Ptr &body,
                                                 const TemplatePattern::Ptr &pattern,
                                                 const QXmlName &mode,
                                                 const TemplateCompilationStage stage)
{
    const char * title;

    switch(stage)
    {
        case TemplateInitial:
        {
            title = "Initial Build";
            break;
        }
        case TemplateTypeCheck:
        {
            title = "Type Check";
            break;
        }
        case TemplateCompress:
        {
            title = "Compression";
            break;
        }
    }

    const QString modeName(Global::namePool()->displayName(mode));
    Q_ASSERT(title);
    ASTItem *const newChild = new ASTItem(m_ast, QLatin1String("T-Rule ")
                                                 + QLatin1String(title)
                                                 + QLatin1String(" mode: ")
                                                 + modeName
                                                 + QLatin1String(" priority: ")
                                                 + QString::number(pattern->priority()));
    m_ast->appendChild(newChild);

    newChild->appendChild(buildASTTree(pattern->matchPattern(), newChild, QPatternist::SequenceType::Ptr()));
    newChild->appendChild(buildASTTree(body, newChild, QPatternist::SequenceType::Ptr()));
}
bool TemplateMode::lessThanByPriority(const TemplatePattern::Ptr &t1,
                                      const TemplatePattern::Ptr &t2)
{
    return t1->priority() > t2->priority();
}