[llvm-commits] [hlvm] r38032 - in /hlvm/trunk: hlvm/Reader/Reader.h hlvm/Reader/XML/XMLReader.cpp tools/hlvm-xml2xml/hlvm-xml2xml.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 16:59:08 PDT 2007
Author: reid
Date: Sat Jul 7 18:59:08 2007
New Revision: 38032
URL: http://llvm.org/viewvc/llvm-project?rev=38032&view=rev
Log:
Incorporate the writing side of hlvm-xml2xml into the program. The skeleton
is now complete.
Modified:
hlvm/trunk/hlvm/Reader/Reader.h
hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
Modified: hlvm/trunk/hlvm/Reader/Reader.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/Reader.h?rev=38032&r1=38031&r2=38032&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/Reader.h (original)
+++ hlvm/trunk/hlvm/Reader/Reader.h Sat Jul 7 18:59:08 2007
@@ -33,7 +33,7 @@
#include <llvm/System/Path.h>
namespace hlvm {
-namespace AST { class AST; }
+namespace AST { class Node; }
class Reader
{
@@ -43,7 +43,7 @@
/// This method retrieves the construct AST that resulted from reading.
/// @returns 0 if nothing has been read yet
- virtual AST::AST* get() = 0;
+ virtual AST::Node* get() = 0;
};
}
#endif
Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp?rev=38032&r1=38031&r2=38032&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul 7 18:59:08 2007
@@ -30,7 +30,6 @@
#include <hlvm/Reader/XML/XMLReader.h>
#include <hlvm/Reader/XML/HLVMTokenizer.h>
#include <hlvm/Base/Locator.h>
-#include <hlvm/AST/AST.h>
#include <hlvm/AST/Bundle.h>
#include <expat.h>
#include <vector>
@@ -110,13 +109,13 @@
class XMLReaderImpl : public XMLReader {
llvm::sys::Path path_;
- AST::AST* ast_;
+ AST::Node* node_;
XML_Parser xp_;
std::vector<ElementInfo> elems_; ///< The element stack
ElementInfo* etop_; ///< A pointer to the top of the element stack
public:
XMLReaderImpl(const llvm::sys::Path& path) :
- path_(path), ast_(0), xp_(0), elems_(), etop_(0)
+ path_(path), node_(0), xp_(0), elems_(), etop_(0)
{
xp_ = XML_ParserCreate( "UTF-8");
// Reserve some space on the elements and attributes list so we aren't
@@ -129,12 +128,12 @@
virtual ~XMLReaderImpl()
{
- if (ast_) delete ast_;
+ if (node_) delete node_;
XML_ParserFree( xp_ );
}
virtual void read();
- virtual AST::AST* get();
+ virtual AST::Node* get();
void CDataSectionStart(void );
void CDataSectionEnd();
@@ -362,18 +361,16 @@
};
-AST::AST*
+AST::Node*
XMLReaderImpl::get()
{
- return ast_;
+ return node_;
}
static const XML_Char Namespace_Separator = 4;
void
XMLReaderImpl::read() {
- ast_ = new AST::AST();
-
// Set up the parser for parsing a document.
XML_ParserReset(xp_,"UTF-8");
XML_SetUserData(xp_, this );
@@ -416,6 +413,7 @@
if (pubid) {
elem.node =
new hlvm::AST::Bundle(static_cast<hlvm::AST::Bundle*>(0),*pubid);
+ node_ = elem.node;
}
break;
}
Modified: hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp?rev=38032&r1=38031&r2=38032&view=diff
==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp Sat Jul 7 18:59:08 2007
@@ -28,6 +28,7 @@
//===----------------------------------------------------------------------===//
#include <hlvm/Reader/XML/XMLReader.h>
+#include <hlvm/Writer/XML/XMLWriter.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/System/Signals.h>
#include <fstream>
@@ -75,7 +76,14 @@
}
XMLReader* rdr = XMLReader::create(llvm::sys::Path(InputFilename));
+ XMLWriter* wrtr = XMLWriter::create(*Out);
rdr->read();
+ AST::Node* node = rdr->get();
+ if (node) {
+ wrtr->write(node);
+ }
+ delete rdr;
+ delete wrtr;
if (Out != &std::cout) {
static_cast<std::ofstream*>(Out)->close();
More information about the llvm-commits
mailing list