-void CYDriver::Clear() {
- state_ = CYClear;
- source_.clear();
- pool_.Clear();
-}
-
-extern int cydebug;
-
-void cy::parser::error(const cy::parser::location_type &loc, const std::string &msg) {
- std::cerr << loc << ": " << msg << std::endl;
-}
-
-void CYConsole(FILE *fin, FILE *fout, FILE *ferr) {
- //cydebug = 1;
-
- CYDriver driver("");
-
- while (!feof(fin)) { _pooled
- driver.Clear();
-
- cy::parser parser(driver);
- if (parser.parse() != 0)
- continue;
-
- for (std::vector<CYSource *>::const_iterator i(driver.source_.begin()); i != driver.source_.end(); ++i) {
- CYSource *source(*i);
-
- std::ostringstream str;
- source->Show(str);
-
- std::string code(str.str());
- std::cout << code << std::endl;
-
- JSStringRef script(JSStringCreateWithUTF8CString(code.c_str()));
-
- JSContextRef context(JSGetContext());
-
- JSValueRef exception(NULL);
- JSValueRef result(JSEvaluateScript(context, script, NULL, NULL, 0, &exception));
- JSStringRelease(script);
-
- if (exception != NULL)
- result = exception;
-
- if (!JSValueIsUndefined(context, result)) {
- CFStringRef json;
-
- @try { json:
- json = JSValueToJSONCopy(context, result);
- } @catch (id error) {
- CYThrow(context, error, &result);
- goto json;
- }
-
- fputs([reinterpret_cast<const NSString *>(json) UTF8String], fout);
- CFRelease(json);
-
- fputs("\n", fout);
- fflush(fout);
- }
- }
- }
+void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
+ CYDriver::Error error;
+ error.location_ = location;
+ error.message_ = message;
+ driver.errors_.push_back(error);