[llvm-commits] [hlvm] r38005 - /hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 16:58:52 PDT 2007
Author: reid
Date: Sat Jul 7 18:58:52 2007
New Revision: 38005
URL: http://llvm.org/viewvc/llvm-project?rev=38005&view=rev
Log:
Add skeleton for YamlReader.
Modified:
hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp
Modified: hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp?rev=38005&r1=38004&r2=38005&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/Yaml/YamlReader.cpp Sat Jul 7 18:58:52 2007
@@ -21,16 +21,50 @@
/// @brief Declares the class hlvm::YamlReader.cpp
////////////////////////////////////////////////////////////////////////////////
-#include "YamlReader.h"
+#include <hlvm/Reader/Yaml/YamlReader.h>
+#include <llvm/System/MappedFile.h>
#include <syck.h>
-namespace hlvm {
+namespace {
-class YamlReaderImpl : public YamlReader {
+class YamlReaderImpl : public hlvm::YamlReader {
+ public:
+ YamlReaderImpl() {
+ parser_ = syck_new_parser();
+ syck_parser_handler(parser_, SyckNodeHandler(NodeHandler));
+ syck_parser_error_handler(parser_, SyckErrorHandler(ErrorHandler));
+ syck_parser_bad_anchor_handler(parser_,
+ SyckBadAnchorHandler(BadAnchorHandler));
+ }
+
+ static SYMID NodeHandler(SyckParser*, SyckNode* )
+ {
+ return 0;
+ }
+
+ static void ErrorHandler(SyckParser*, char*)
+ {
+ }
+
+ static SyckNode* BadAnchorHandler(SyckParser*, char*)
+ {
+ return 0;
+ }
+
+ void parse(const llvm::sys::Path& path) {
+ llvm::sys::MappedFile mapfile(path);
+ mapfile.map();
+ syck_parser_str(parser_, mapfile.charBase(), mapfile.size(),0);
+ root_ = syck_parse(parser_);
+ }
+
+ private:
+ SyckParser* parser_;
+ SYMID root_;
};
-YamlReader* YamlReader::create() {
+} // anonymous
+
+hlvm::YamlReader* hlvm::YamlReader::create() {
return new YamlReaderImpl();
}
-
-} // hlvm
More information about the llvm-commits
mailing list