//  -*- c++ -*-

#ifndef XPATH_EXPRESSION_H
#define XPATH_EXPRESSION_H

#include <xpath/value.h>

namespace XPath {

class Context;

/**
 * The AST of an XPath expression.
 *
 * @version $Id: xmldemo.h,v 1.3 2002/02/18 00:45:47 rich Exp $
 * @author Richard Moore, rich@kde.org 
 */
class ExpressionNode
{
public:
    enum NodeType {
	NodeExpression, NodeAbbreviated
    };

    ExpressionNode() { tp = NodeExpression; }
    ExpressionNode( NodeType nt ) { tp = nt; }
    virtual ~ExpressionNode() {}

    NodeType type() const { return tp; }

    virtual Value evaluate( const Context &context );
    virtual bool match( const Context &context, const DOM::Node &node );

private:
    NodeType tp;
};

/** An AST node for abbreviated expressions. */
class ExpressionAbbr : public ExpressionNode
{
public:
    enum AbbrType {
	AbbrCurrent, AbbrParent,
	AbbrChildren, AbbrDescendents, AbbrAttribute
    };

    ExpressionAbbr( AbbrType abbr, const QString &token=QString::null );

    virtual Value evaluate( const Context &context );
    virtual bool match( const Context &context, const DOM::Node &node );

private:
    int abbr;
    QString arg;
};

}; // namespace XPath

#endif // XPATH_EXPRESSION_H

// Local Variables:
// c-basic-offset: 4
// End:
