Main Page | Class Hierarchy | Class List | File List | Class Members

source.h

00001 /*********************************************************************
00002  *
00003  * Condor ClassAd library
00004  * Copyright (C) 1990-2003, Condor Team, Computer Sciences Department,
00005  * University of Wisconsin-Madison, WI and Rajesh Raman.
00006  *
00007  * This source code is covered by the Condor Public License, which can
00008  * be found in the accompanying LICENSE file, or online at
00009  * www.condorproject.org.
00010  *
00011  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00012  * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR
00013  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00014  * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS
00015  * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT
00016  * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON
00017  * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS,
00018  * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY
00019  * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY
00020  * RIGHT.
00021  *
00022  *********************************************************************/
00023 
00024 #ifndef __SOURCE_H__
00025 #define __SOURCE_H__
00026 
00027 #include <vector>
00028 #include <iostream>
00029 #include "lexer.h"
00030 
00031 BEGIN_NAMESPACE( classad )
00032 
00033 class ClassAd;
00034 class ExprTree;
00035 class ExprList;
00036 class FunctionCall;
00037 
00040 class ClassAdParser
00041 {
00042         public:
00044                 ClassAdParser();
00045 
00047                 ~ClassAdParser();
00048 
00058                 ClassAd *ParseClassAd(const std::string &buffer, bool full=false);
00059                 ClassAd *ParseClassAd(const std::string &buffer, int &offset);
00060                 ClassAd *ParseClassAd(const char *buffer, bool full=false);
00061                 ClassAd *ParseClassAd(const char *buffer, int &offset);
00062                 ClassAd *ParseClassAd(FILE *file, bool full=false);
00063                 ClassAd *ParseClassAd(std::istream &stream, bool full=false);
00064 
00065                 ClassAd *ParseClassAd(LexerSource *lexer_source, bool full=false);
00066 
00076                 bool ParseClassAd(const std::string &buffer, ClassAd &ad, bool full=false);
00077                 bool ParseClassAd(const std::string &buffer, ClassAd &classad, int &offset);
00078                 bool ParseClassAd(const char *buffer, ClassAd &classad, bool full=false);
00079                 bool ParseClassAd(const char *buffer, ClassAd &classad, int &offset);
00080                 bool ParseClassAd(FILE *file, ClassAd &classad, bool full=false);
00081                 bool ParseClassAd(std::istream &stream, ClassAd &classad, bool full=false);
00082 
00083                 bool ParseClassAd(LexerSource *lexer_source, ClassAd &ad, bool full=false);
00084 
00094                 bool ParseExpression( const std::string &buffer, ExprTree*& expr, 
00095                                         bool full=false);
00096 
00097                 bool ParseExpression( LexerSource *lexer_source, ExprTree*& expr, 
00098                                         bool full=false);
00099 
00109                 ExprTree *ParseExpression( const std::string &buffer, bool full=false);
00110 
00111                 ExprTree *ParseExpression( LexerSource *lexer_source, bool full=false);
00112 
00113         ExprTree *ParseNextExpression(void);
00114 
00115                 void SetDebug( bool d ) { lexer.SetDebug( d ); }
00116 
00117                 Lexer::TokenType PeekToken(void);
00118                 Lexer::TokenType ConsumeToken(void);
00119 
00120         private:
00121                 // lexical analyser for parser
00122                 Lexer   lexer;
00123 
00124                 // mutually recursive parsing functions
00125                 bool parseExpression( ExprTree*&, bool=false);
00126                 bool parseClassAd( ClassAd&, bool=false);
00127                 bool parseExprList( ExprList*&, bool=false);
00128                 bool parseLogicalORExpression( ExprTree*& );
00129                 bool parseLogicalANDExpression( ExprTree*& );
00130                 bool parseInclusiveORExpression( ExprTree*& );
00131                 bool parseExclusiveORExpression( ExprTree*& );
00132                 bool parseANDExpression( ExprTree*& );
00133                 bool parseEqualityExpression( ExprTree*& );
00134                 bool parseRelationalExpression( ExprTree*& );
00135                 bool parseShiftExpression( ExprTree*& );
00136                 bool parseAdditiveExpression( ExprTree*& );
00137                 bool parseMultiplicativeExpression( ExprTree*& );
00138                 bool parseUnaryExpression( ExprTree*& );
00139                 bool parsePostfixExpression( ExprTree*& );
00140                 bool parsePrimaryExpression( ExprTree*& );
00141                 bool parseArgumentList( std::vector<ExprTree*>& );
00142 
00143                 bool shouldEvaluateAtParseTime(const std::string &functionName,
00144                                 std::vector<ExprTree*> &argList);
00145                 ExprTree *evaluateFunction(const std::string &functionName,
00146                                 std::vector<ExprTree*> &argList);
00147 
00148 };
00149 
00150 std::istream & operator>>(std::istream &stream, ClassAd &ad);
00151 
00152 END_NAMESPACE // classad
00153 
00154 #endif//__SOURCE_H__