torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EdifParser.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef HAVE_CONFIG_H
17 #include "torc/generic/config.h"
18 #endif
19 
24 #include "torc/generic/Root.hpp"
26 
27 namespace torc {
28 namespace generic {
29 
31 
33 
35 
37  return *this;
38 }
39 
40 void EdifParser::parse(const std::string& inFileName, const RootSharedPtr& outRoot,
41  const LinkerSharedPtr& outLinker, const ObjectFactorySharedPtr& inFactory,
42  const ParserOptions& inOptions) throw (Error) {
43  EdifContextSharedPtr context(new EdifContext(outRoot, outLinker, inFactory, inOptions));
44  if(!outRoot || !outLinker || !inFactory) {
45  Error e(eMessageIdErrorNullPointer, __FUNCTION__, __FILE__, __LINE__);
46  throw;
47  }
48  Driver parserDriver(context);
49  if(false == parserDriver.parseFile(inFileName)) {
50  throw parserDriver.getParserError();
51  }
52  return;
53 }
54 
55 void EdifParser::parse(const std::vector<std::string>& inFileNames, const RootSharedPtr& outRoot,
56  const LinkerSharedPtr& outLinker, const ObjectFactorySharedPtr& inFactory,
57  const ParserOptions& inOptions) throw (Error) {
58  std::vector<std::string>::const_iterator it = inFileNames.begin();
59  std::vector<std::string>::const_iterator end = inFileNames.end();
60  try {
61  for(; it != end; ++it) {
62  parse(*it, outRoot, outLinker, inFactory, inOptions);
63  }
64  } catch(Error& e) {
65  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
66  throw;
67  }
68 }
69 
70 } // namespace generic
71 } // namespace torc
boost::shared_ptr< EdifContext > EdifContextSharedPtr
The Top level parser for parsing EDIF files.
Definition: EdifParser.hpp:41
boost::shared_ptr< Linker > LinkerSharedPtr
boost::shared_ptr< ObjectFactory > ObjectFactorySharedPtr
std::string string
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
Error getParserError() const
Definition: Driver.hpp:131
bool parseFile(const std::string &inFileName)
Definition: Driver.cpp:64
EdifParser & operator=(const EdifParser &inSource)
Definition: EdifParser.cpp:36
boost::shared_ptr< Root > RootSharedPtr
void parse(const std::string &inFileName, const RootSharedPtr &outRoot, const LinkerSharedPtr &outLinker, const ObjectFactorySharedPtr &inFactory, const ParserOptions &inOptions)
Definition: EdifParser.cpp:40
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73