(file) Return to parser.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler

  1 martin 1.25 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.26 //
  3 martin 1.25 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.26 //
 10 martin 1.25 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.26 //
 17 martin 1.25 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.26 //
 20 martin 1.25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.26 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.26 //
 28 martin 1.25 //////////////////////////////////////////////////////////////////////////
 29 mike   1.9  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32 jim.wunderlich 1.20 // bug 4573 - cimmof include file search path processing is inadequate
 33                     //
 34                     // Bug 4573 changed the behavior of the processing for locating specified
 35 karl           1.23 //  include files. The new procssing is based on the include file processing
 36 jim.wunderlich 1.20 //  behaviour used by the C compiler.
 37                     //
 38                     //      The search path for included files previously was:
 39                     //          1. try to open the file in the current working directory.
 40                     //          2. process the include path array from the cimof(l) cmdline
 41                     //             processing which always include "dot" as a default search
 42 karl           1.23 //             path and then any paths specified on the command line
 43 jim.wunderlich 1.20 //             with the -I option.
 44                     //
 45                     //      The search path for included files now is:
 46                     //          1. try to open the file in the same directory as the current
 47                     //             file being processed.
 48                     //          2. process the include path array from the cimof(l) cmdline
 49 karl           1.23 //             processing which only includes paths specified on the
 50 jim.wunderlich 1.20 //             command line with the -I option.
 51                     //
 52 mike           1.9  
 53                     //
 54 karl           1.23 // implementation of valueFactory
 55 mike           1.9  //
 56                     //
 57                     //
 58                     // implementation of those methods  of class parser which are not pure
 59                     // virtual
 60                     //
 61                     
 62                     #include "parser.h"
 63                     //#include <sstream>
 64                     #include "parserExceptions.h"
 65                     
 66                     //---------------------------------------------------------------------
 67                     // Take a YY_BUFFERSTATE off the stack of saved contexts
 68                     //---------------------------------------------------------------------
 69                     bufstate *
 70 karl           1.23 parser::pop_statebuff()
 71                     {
 72 mike           1.9      bufstate *v = 0;
 73 karl           1.23     if (!_include_stack.isEmpty())
 74                         {
 75                             v = _include_stack.top();
 76                             _include_stack.pop();
 77 mike           1.9      }
 78                         return v;
 79                     }
 80                     
 81                     //-------------------------------------------------------------------
 82                     // Create a flex input buffer from a String containing the file name
 83                     //-------------------------------------------------------------------
 84 karl           1.23 int parser::setInputBufferFromName(const String &filename)
 85                     {
 86 ouyang.jian    1.22 #if defined (PEGASUS_OS_VMS)
 87 karl           1.23     FILE *f = fopen(filename.getCString(),"r");
 88 chuck          1.13 #else
 89 karl           1.23     FILE *f = fopen(filename.getCString(),"rt");
 90 chuck          1.13 #endif
 91 karl           1.23     if (f) {
 92                             set_current_filename(filename);
 93                             set_lineno(1);
 94                             return setInputBuffer(f, false);
 95                         } else {
 96                             return 1;
 97                         }
 98 mike           1.9  }
 99                     
100                     //-----------------------------------------------------------------
101                     // Handle the end of an input buffer.  Either there is saved context
102                     // or there isn't.  If there is, restore the saved particulars
103                     // of that context so we can keep on parsing
104                     //-----------------------------------------------------------------
105 karl           1.23 int parser::wrap()
106                     {
107                         bufstate *v = pop_statebuff();
108                         if (v)
109                         {
110                             setInputBuffer(v->buffer_state, true);
111                             set_current_filename(v->filename);
112                             set_lineno(v->lineno);
113                             set_current_filenamePath(v->filenamePath);
114                             delete v;
115                             return 0;  // more data available
116                         } else {
117                             return 1;  // end of it all
118                         }
119 mike           1.9  }
120                     
121                     #ifdef PEGASUS_HAVE_NAMESPACES
122                     using namespace ParserExceptions;
123                     #endif /* PEGASUS_HAVE_NAMESPACES */
124                     
125                     //----------------------------------------------------------------
126 karl           1.10 // ATTN: P2 BB 2001 Log where an error occured.  This is lame, so it needs work
127 karl           1.23 //
128 mike           1.9  //----------------------------------------------------------------
129 karl           1.23 void parser::log_parse_error(char *token, const char *errmsg) const
130                     {
131                         char buf[40];
132 kumpf          1.24     sprintf(buf, "%u", _lineno);
133 karl           1.23     String s = _current_filename + ":" + buf + ": " + errmsg + " before `"
134                             + token + "'\n";
135                         throw ParserLexException(s);
136 mike           1.9  }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2