Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/cppparser/cppExpressionParser.cxx

Go to the documentation of this file.
00001 // Filename: cppExpressionParser.cxx
00002 // Created by:  drose (25Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #include "cppExpressionParser.h"
00021 #include "cppExpression.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: CPPExpressionParser::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 CPPExpressionParser::
00029 CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope) :
00030   _current_scope(current_scope),
00031   _global_scope(global_scope)
00032 {
00033   _expr = NULL;
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: CPPExpressionParser::Destructor
00038 //       Access: Public
00039 //  Description:
00040 ////////////////////////////////////////////////////////////////////
00041 CPPExpressionParser::
00042 ~CPPExpressionParser() {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: CPPExpressionParser::parse_expr
00047 //       Access: Public
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 bool CPPExpressionParser::
00051 parse_expr(const string &expr) {
00052   if (!init_const_expr(expr)) {
00053     cerr << "Unable to parse expression\n";
00054     return false;
00055   }
00056 
00057   _expr = parse_const_expr(this, _current_scope, _global_scope);
00058 
00059   return get_error_count() == 0;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: CPPExpressionParser::parse_expr
00064 //       Access: Public
00065 //  Description:
00066 ////////////////////////////////////////////////////////////////////
00067 bool CPPExpressionParser::
00068 parse_expr(const string &expr, const CPPPreprocessor &filepos) {
00069   if (!init_const_expr(expr)) {
00070     cerr << "Unable to parse expression\n";
00071     return false;
00072   }
00073 
00074   copy_filepos(filepos);
00075 
00076   _expr = parse_const_expr(this, _current_scope, _global_scope);
00077 
00078   return get_error_count() == 0;
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: CPPExpressionParser::output
00083 //       Access: Public
00084 //  Description:
00085 ////////////////////////////////////////////////////////////////////
00086 void CPPExpressionParser::
00087 output(ostream &out) const {
00088   if (_expr == NULL) {
00089     out << "(null expr)";
00090   } else {
00091     out << *_expr;
00092   }
00093 }

Generated on Thu May 1 22:12:51 2003 for DTool by doxygen1.3