• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/xml/xpath/private/XPathParser.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _xpathparser_h
00018 #define _xpathparser_h
00019 
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022 #include <spl/collection/Array.h>
00023 #include <spl/Memory.h>
00024 #include <spl/collection/List.h>
00025 #include <spl/String.h>
00026 #include <spl/collection/Vector.h>
00027 #include <spl/xml/xpath/private/XPathLex.h>
00028 #include <spl/xml/xpath/private/XPathOperator.h>
00029 
00030 class XPathParser : public IMemoryValidate
00031 {
00032 private:
00033         XPathLex m_lex;
00034         Vector<XPathOperatorPtr> *m_out;
00035         List<String> m_exprStack;
00036         
00037 public:
00038         XPathParser();
00039         XPathParser(const XPathParser& parser);
00040         virtual ~XPathParser();
00041 
00042         XPathParser& operator =(const XPathParser& parser);
00043 
00044         Array<XPathOperatorPtr> Parse(const String& expr);
00045 
00046 #if defined(DEBUG) || defined(_DEBUG)
00047         void CheckMem() const;
00048         void ValidateMem() const;
00049 #endif
00050 
00051 private:
00052         void NodeSpec();
00053         void NodePath();
00054         void MorePath();
00055         bool Axis();
00056         bool Predicate();
00057         bool MoreMorePath();
00058         bool Expr();
00059         bool MoreExpr();
00060         void LogOp();
00061         bool MoreLogOp();
00062         bool MoreRelOps();
00063         void RelOp();
00064         void Term();
00065         bool MoreTerms();
00066         void Factor();
00067         bool MoreFactors();
00068         bool PathExpr();
00069         bool ArgList();
00070         bool MoreArgs();
00071 };
00072 
00073 #endif