1 karl 1.21 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.9 //
|
3 karl 1.17 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.16 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.17 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.21 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.9 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.12 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.9 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.9 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.12 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.9 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Bob Blair (bblair@bmc.com)
33 //
34 // Modified By:
|
35 gs.keenan 1.19 // Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
|
36 jim.wunderlich 1.20 // Jim Wunderlich (Jim_Wunderlich@prodigy.net)
|
37 mike 1.9 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
|
40 jim.wunderlich 1.20 // bug 4573 - cimmof include file search path processing is inadequate
41 //
42 // Bug 4573 changed the behavior of the processing for locating specified
43 // include files. The new procssing is based on the include file processing
44 // behaviour used by the C compiler.
45 //
46 // The search path for included files previously was:
47 // 1. try to open the file in the current working directory.
48 // 2. process the include path array from the cimof(l) cmdline
49 // processing which always include "dot" as a default search
50 // path and then any paths specified on the command line
51 // with the -I option.
52 //
53 // The search path for included files now is:
54 // 1. try to open the file in the same directory as the current
55 // file being processed.
56 // 2. process the include path array from the cimof(l) cmdline
57 // processing which only includes paths specified on the
58 // command line with the -I option.
59 //
|
60 mike 1.9
61 //
62 // implementation of valueFactory
63 //
64 //
65 //
66 // implementation of those methods of class parser which are not pure
67 // virtual
68 //
69
70 #include "parser.h"
71 //#include <sstream>
72 #include "parserExceptions.h"
73
74 //---------------------------------------------------------------------
75 // Take a YY_BUFFERSTATE off the stack of saved contexts
76 //---------------------------------------------------------------------
77 bufstate *
78 parser::pop_statebuff() {
79 bufstate *v = 0;
80 if (!_include_stack.isEmpty()) {
81 mike 1.9 v = _include_stack.top();
82 _include_stack.pop();
83 }
84 return v;
85 }
86
87 //-------------------------------------------------------------------
88 // Create a flex input buffer from a String containing the file name
89 //-------------------------------------------------------------------
90 int
91 parser::setInputBufferFromName(const String &filename) {
|
92 gs.keenan 1.19 #if defined PEGASUS_PLATFORM_OS400_ISERIES_IBM || defined (PEGASUS_OS_VMS)
|
93 chuck 1.13 // 't' not supported on OS/400
|
94 kumpf 1.14 FILE *f = fopen(filename.getCString(),"r");
|
95 chuck 1.13 #else
|
96 kumpf 1.14 FILE *f = fopen(filename.getCString(),"rt");
|
97 chuck 1.13 #endif
|
98 mike 1.9 if (f) {
99 set_current_filename(filename);
100 set_lineno(1);
|
101 kumpf 1.15 return setInputBuffer(f, false);
|
102 mike 1.9 } else {
103 return 1;
104 }
105 }
106
107 //-----------------------------------------------------------------
108 // Handle the end of an input buffer. Either there is saved context
109 // or there isn't. If there is, restore the saved particulars
110 // of that context so we can keep on parsing
111 //-----------------------------------------------------------------
112 int
113 parser::wrap() {
114 bufstate *v = pop_statebuff();
115 if (v) {
|
116 kumpf 1.15 setInputBuffer(v->buffer_state, true);
|
117 mike 1.9 set_current_filename(v->filename);
118 set_lineno(v->lineno);
|
119 jim.wunderlich 1.20 set_current_filenamePath(v->filenamePath);
|
120 mike 1.9 delete v;
121 return 0; // more data available
122 } else {
123 return 1; // end of it all
124 }
125 }
126
127 #ifdef PEGASUS_HAVE_NAMESPACES
128 using namespace ParserExceptions;
129 #endif /* PEGASUS_HAVE_NAMESPACES */
130
131 //----------------------------------------------------------------
|
132 karl 1.10 // ATTN: P2 BB 2001 Log where an error occured. This is lame, so it needs work
133 //
|
134 mike 1.9 //----------------------------------------------------------------
135 void
|
136 kumpf 1.11 parser::log_parse_error(char *token, const char *errmsg) const {
|
137 mike 1.9 char buf[40];
138 sprintf(buf, "%d", _lineno);
139 String s = _current_filename + ":" + buf + ": " + errmsg + " before `"
140 + token + "'\n";
|
141 kumpf 1.14 throw ParserLexException(s);
|
142 mike 1.9 }
|