]> git.saurik.com Git - cycript.git/blobdiff - Library.cpp
Remove ?syntax and set failure exit code on throw.
[cycript.git] / Library.cpp
index b04f2caecff5e6eb99ad37f27a67f630e395714b..59decd8351cd0b4e4f463e2b1d1ea7c2238b55cb 100644 (file)
 **/
 /* }}} */
 
-#include <dlfcn.h>
-
 #include "cycript.hpp"
 
-#include "Pooling.hpp"
-
-#include <sys/mman.h>
-
 #include <iostream>
 #include <set>
 #include <map>
 #include <sstream>
 #include <cmath>
 
-#include "Error.hpp"
-#include "Execute.hpp"
-#include "Parser.hpp"
-#include "String.hpp"
+#include <dlfcn.h>
 
-#include "Cycript.tab.hh"
-#include "Driver.hpp"
+#include <sys/mman.h>
 
 #include "ConvertUTF.h"
+#include "Driver.hpp"
+#include "Error.hpp"
+#include "Execute.hpp"
+#include "Pooling.hpp"
+#include "String.hpp"
+#include "Syntax.hpp"
 
 template <>
 ::pthread_key_t CYLocal<CYPool>::key_ = Key_();
@@ -217,21 +213,23 @@ double CYCastDouble(const char *value) {
     return CYCastDouble(value, strlen(value));
 }
 
+_visible bool CYStartsWith(const CYUTF8String &haystack, const CYUTF8String &needle) {
+    return haystack.size >= needle.size && strncmp(haystack.data, needle.data, needle.size) == 0;
+}
+
 CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream) {
     CYLocalPool local;
-    CYDriver driver(stream);
-
-    cy::parser parser(driver);
-    _assert(parser.parse() == 0);
+    CYDriver driver(local, stream);
+    _assert(!driver.Parse());
     _assert(driver.errors_.empty());
 
     CYOptions options;
     CYContext context(options);
-    driver.program_->Replace(context);
+    driver.script_->Replace(context);
 
     std::stringbuf str;
     CYOutput out(str, options);
-    out << *driver.program_;
+    out << *driver.script_;
     return $pool.strdup(str.str().c_str());
 }