X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/c1d3e52e58e86c49f9d04e06ae8e0ece4b98250c..fc8fc33d0c3a25e23e354fed740ff500fab218d9:/Driver.cpp diff --git a/Driver.cpp b/Driver.cpp index 7e9c7ad..387a46d 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -22,19 +22,23 @@ #include "Cycript.tab.hh" #include "Driver.hpp" -CYDriver::CYDriver(std::istream &data, const std::string &filename) : - state_(CYClear), +CYDriver::CYDriver(CYPool &pool, std::istream &data, const std::string &filename) : + pool_(pool), + newline_(false), + last_(false), data_(data), + debug_(0), strict_(false), - commented_(false), + highlight_(false), filename_(filename), - program_(NULL), + script_(NULL), auto_(false), context_(NULL), mode_(AutoNone) { memset(&no_, 0, sizeof(no_)); in_.push(false); + template_.push(false); ScannerInit(); } @@ -42,6 +46,21 @@ CYDriver::~CYDriver() { ScannerDestroy(); } +bool CYDriver::Parse() { + CYLocal local(&pool_); + cy::parser parser(*this); +#ifdef YYDEBUG + parser.set_debug_level(debug_); +#endif + return parser.parse() != 0; +} + +void CYDriver::Replace(CYOptions &options) { + CYLocal local(&pool_); + CYContext context(options); + script_->Replace(context); +} + void CYDriver::Warning(const cy::parser::location_type &location, const char *message) { if (!strict_) return;